-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@0.4.0: Streamlined and enhanced components (#9)
CartBlancheBlock, a better CardBlock, EnhHeadingBlock a better HeadingBlock, GridBlock, a more complete and useful GroupBlock BulletCardsBlock: common simple case InlineIcon ImageBlock now auto scales to 0.75 on mobile VideoBlock: support for mobile sizing using 'vw' eg: {mobile: {vw: 60}} common/ChatWidget (from PR #7) Removed esbuild step and single entry point (client code must import using subdirs) Minor cleanup in tsconfig --------- Co-authored-by: artem ash <[email protected]> --------- Co-authored-by: Erik Rakušček <[email protected]>
- Loading branch information
1 parent
eb2fe26
commit 9a0a7d7
Showing
32 changed files
with
877 additions
and
116 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
|
||
import type BlockComponentProps from './block-component-props' | ||
import GridBlockComponent from './grid-block' | ||
import type { Block, BulletCardsBlock } from '../def' | ||
import InlineIcon from './inline-icon' | ||
|
||
const BulletCardsBlockComponent: React.FC<BlockComponentProps> = ({ | ||
block, | ||
className='', | ||
agent | ||
}) => { | ||
|
||
if (block.blockType !== 'bullet-cards') { | ||
return <>bullet cards block required</> | ||
} | ||
const b = block as BulletCardsBlock | ||
|
||
return ( | ||
<GridBlockComponent block={{blockType: 'grid', grid: b.grid} as Block} className={className} agent={agent}> | ||
{b.cards.map((card, index) => ( | ||
<div key={index} className='md:border md:border-muted-2 rounded px-6 py-1 md:py-4 flex flex-row justify-start items-center not-typography'> | ||
<InlineIcon icon={card.icon} size={b.iconSize ?? 28} agent={agent}/> | ||
<p className='m-0'>{card.text}</p> | ||
</div> | ||
))} | ||
</GridBlockComponent> | ||
) | ||
} | ||
|
||
export default BulletCardsBlockComponent |
98 changes: 98 additions & 0 deletions
98
pkgs/luxdefi-ui/blocks/components/carte-blanche-block/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import React from 'react' | ||
|
||
import { | ||
Card, | ||
CardContent, | ||
CardFooter, | ||
CardHeader, | ||
} from '../../../primitives' | ||
|
||
import { cn, containsToken } from '../../../util' | ||
|
||
import { | ||
getSpecifierData, | ||
getPrimaryStartingWith, | ||
getDim, | ||
} from '../../../util/specifier' | ||
|
||
import type CarteBlancheBlock from '../../def/carte-blanche-block' | ||
|
||
import CTABlockComponent from '../cta-block' | ||
import Content from '../content' | ||
import type BlockComponentProps from '../block-component-props' | ||
import { EnhHeadingBlockComponent } from '..' | ||
|
||
type CardSection = 'entire' | 'header' | 'content' | 'footer' | ||
|
||
const _getClx = (specifier: string, section: CardSection): string => { | ||
let result = '' | ||
if (specifier === 'big-padding') { | ||
switch (section) { | ||
// defaults: p-4 lg:p-6 xl:p-8 | ||
case 'header': { | ||
result = 'md:p-8 lg:p-12 xl:p-16' | ||
} break | ||
} | ||
} | ||
else if (specifier === 'no-inner-borders') { | ||
switch (section) { | ||
case 'header': { | ||
result = 'border-none' | ||
} break | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
const CarteBlancheBlockComponent: React.FC< | ||
BlockComponentProps | ||
> = ({ | ||
block, | ||
className='', | ||
agent, | ||
}) => { | ||
|
||
if (block.blockType !== 'carte-blanche') { | ||
return <>carte blanche block required</> | ||
} | ||
|
||
const b = block as CarteBlancheBlock | ||
|
||
const specified = (s: string): boolean => (containsToken(b.specifiers, s)) | ||
const getClx = (specifier: string, section: CardSection): string => ( | ||
(specified(specifier)) ? _getClx(specifier, section) : '' | ||
) | ||
|
||
//const bigPadding = specified('big-padding') | ||
|
||
const headingclx = [ | ||
getClx('big-padding', 'header'), | ||
getClx('no-inner-borders', 'header'), | ||
].join(' ') | ||
|
||
return ( | ||
<Card className={cn('flex flex-col ', className)} > | ||
{b.heading && ( | ||
<CardHeader className={cn('typography-img:m-0', headingclx)} > | ||
{b.topContent && ( | ||
<Content blocks={b.topContent} agent={agent} className=''/> | ||
)} | ||
<EnhHeadingBlockComponent block={b.heading} className='text-accent' agent={agent}/> | ||
</CardHeader> | ||
)} | ||
{b.content && ( | ||
<CardContent className={cn('typography flex flex-col justify-center', className)}> | ||
<Content blocks={b.content} agent={agent}/> | ||
</CardContent> | ||
)} | ||
{b.cta && ( | ||
<CardFooter className={'grid grid-cols-1 gap-2 md:flex md:flex-row md:justify-center ' /*+ paddingclx*/} > | ||
<CTABlockComponent block={b.cta} agent={agent}/> | ||
</CardFooter> | ||
)} | ||
</Card> | ||
) | ||
} | ||
|
||
export default CarteBlancheBlockComponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.