Skip to content

Commit 2cb51d0

Browse files
authored
add variant and size for blockquote (#922)
1 parent 07ced7f commit 2cb51d0

File tree

10 files changed

+169
-7
lines changed

10 files changed

+169
-7
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { getSourceCodeFromPath } from '@/utils/parseSourceCode';
2+
3+
const blockQuoteColorSourceCode = await getSourceCodeFromPath('docs/app/docs/components/blockquote/examples/BlockQuoteColor.tsx');
4+
5+
export const code = {
6+
javascript: {
7+
code: blockQuoteColorSourceCode
8+
}
9+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { getSourceCodeFromPath } from '@/utils/parseSourceCode';
2+
3+
const blockQuoteSizesSourceCode = await getSourceCodeFromPath('docs/app/docs/components/blockquote/examples/BlockQuoteSizes.tsx');
4+
5+
export const code = {
6+
javascript: {
7+
code: blockQuoteSizesSourceCode
8+
}
9+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { getSourceCodeFromPath } from '@/utils/parseSourceCode';
2+
3+
const blockQuoteVariantsSourceCode = await getSourceCodeFromPath('docs/app/docs/components/blockquote/examples/BlockQuoteVariants.tsx');
4+
5+
export const code = {
6+
javascript: {
7+
code: blockQuoteVariantsSourceCode
8+
}
9+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import BlockQuote from '@radui/ui/BlockQuote';
2+
3+
4+
const BlockQuoteColor = () => {
5+
const sizes = ['small', 'medium', 'large', 'x-large'];
6+
return <div className='flex flex-col gap-4'>
7+
{sizes.map((size, index) => {
8+
return <BlockQuote key={index} size={size} color='pink'>
9+
"Behind every great man is a woman rolling her eyes." — Jim Carrey
10+
</BlockQuote>
11+
})}
12+
</div>
13+
}
14+
15+
export default BlockQuoteColor;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import BlockQuote from '@radui/ui/BlockQuote';
2+
3+
const BlockQuoteSizes = () => {
4+
const sizes = ['small', 'medium', 'large', 'x-large'];
5+
6+
return <div className='flex flex-col gap-4'>
7+
8+
{sizes.map((size, index) => {
9+
return <BlockQuote key={index} size={size} >
10+
<span>"Behind every great man is a woman rolling her eyes." — Jim Carrey</span>
11+
</BlockQuote>
12+
})}
13+
</div>
14+
15+
}
16+
17+
export default BlockQuoteSizes;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
const BlockQuoteVariants = () => {
3+
return <div>
4+
5+
</div>
6+
7+
};
8+
9+
export default BlockQuoteVariants;
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import Documentation from "@/components/layout/Documentation/Documentation"
22
import codeUsage, { BlockQuoteTable } from "./docs/codeUsage"
33
import BlockQuote from "@radui/ui/BlockQuote"
4+
import { code as variantCodeUsage } from './docs/variantCodeUsage';
5+
import { code as sizeCodeUsage } from './docs/sizeCodeUsage';
6+
import { code as colorCodeUsage } from './docs/colorCodeUsage';
7+
import BlockQuoteVariants from './examples/BlockQuoteVariants';
8+
import BlockQuoteSizes from './examples/BlockQuoteSizes';
9+
import BlockQuoteColor from './examples/BlockQuoteColor';
410

511
<Documentation title={`BlockQuote`} description={`
612
BlockQuote is used to display a quote.
@@ -11,12 +17,21 @@ import BlockQuote from "@radui/ui/BlockQuote"
1117
"Behind every great man is a woman rolling her eyes." — Jim Carrey
1218
</BlockQuote>
1319

14-
15-
1620
</Documentation.ComponentHero>
1721

18-
19-
<Documentation.Table columns={BlockQuoteTable.columns} data={BlockQuoteTable.data} />
20-
22+
<Documentation.Table columns={BlockQuoteTable.columns} data={BlockQuoteTable.data} />
23+
24+
<Documentation.ComponentHero title='Variants' codeUsage={variantCodeUsage}>
25+
<BlockQuoteVariants />
26+
</Documentation.ComponentHero>
27+
28+
29+
<Documentation.ComponentHero title='Sizes' codeUsage={sizeCodeUsage}>
30+
<BlockQuoteSizes />
31+
</Documentation.ComponentHero>
32+
33+
<Documentation.ComponentHero title='Color' codeUsage={colorCodeUsage}>
34+
<BlockQuoteColor />
35+
</Documentation.ComponentHero>
2136

2237
</Documentation>

src/components/ui/BlockQuote/BlockQuote.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,29 @@ export type BlockQuoteProps = {
99
children: React.ReactNode;
1010
customRootClass?: string;
1111
className?: string;
12-
color?:string;
12+
color?: string;
13+
variant?: string;
14+
size?: string;
1315
props?: Record<string, any>[]
1416
}
15-
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', ...props }: BlockQuoteProps) => {
17+
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', variant= '', size= '', ...props }: BlockQuoteProps) => {
1618
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
1719

1820
const data_attributes: Record<string, string> = {};
1921

22+
if (variant) {
23+
data_attributes['data-block-quote-variant'] = variant;
24+
}
25+
26+
if (size) {
27+
data_attributes['data-block-quote-size'] = size;
28+
}
29+
30+
2031
if (color) {
2132
data_attributes['data-accent-color'] = color;
2233
}
34+
2335

2436
return <blockquote className={clsx(rootClass, className)} {...props} {...data_attributes}> {children}</blockquote>;
2537
};

src/components/ui/BlockQuote/stories/BlockQuote.stories.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const BLOCKQUOTE_TEXT = `Avian carriers can provide high delay, low throughput,
1111
avoidance system, which increases availability.`;
1212

1313
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
14+
const Variants = []; // TODO
15+
const Sizes = ['small', 'medium', 'large', 'x-large'];
16+
1417
export default {
1518
title: 'Components/BlockQuote',
1619
component: BlockQuote,
@@ -39,3 +42,38 @@ export const Color = {
3942
color: 'blue'
4043
}
4144
};
45+
46+
export const Size = () => {
47+
return <SandboxEditor>
48+
<div className='mt-4 mb-2'>
49+
<p className='text-gray-950'>BlockQuote Size</p>
50+
</div>
51+
<div>
52+
53+
<div className='mb-10'>
54+
<span className="flex flex-col gap-3">
55+
{Sizes.map((size, index) => {
56+
return <BlockQuote key={index} size={size} >
57+
<div>{BLOCKQUOTE_TEXT} </div>
58+
</BlockQuote>;
59+
})}
60+
</span>
61+
</div>
62+
63+
</div>
64+
</SandboxEditor>;
65+
};
66+
67+
export const Variant = () => {
68+
return <SandboxEditor>
69+
<div className='mt-4 mb-2'>
70+
<p className='text-gray-950'>BlockQuote Variant</p>
71+
</div>
72+
<div className='flex flex-col gap-3'>
73+
{/* TODO */}
74+
<BlockQuote>
75+
<div>{BLOCKQUOTE_TEXT}</div>
76+
</BlockQuote>
77+
</div>
78+
</SandboxEditor>;
79+
};

styles/themes/components/blockquote.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,33 @@
22
border-color: var(--rad-ui-color-accent-600);
33
border-left-width: 0.5rem;
44
padding-left: 0.75rem; // Assuming 1rem = 16px
5+
6+
// BlockQuote Variants - TODO
7+
8+
/** BlockQuote Sizes */
9+
&[data-block-quote-size="small"]{
10+
font-size: small;
11+
padding: 4px 10px;
12+
13+
}
14+
15+
&[data-block-quote-size="medium"]{
16+
font-size: medium;
17+
padding: 4px 10px;
18+
19+
}
20+
21+
&[data-block-quote-size="large"]{
22+
font-size: large;
23+
padding: 4px 10px;
24+
25+
}
26+
27+
&[data-block-quote-size="x-large"]{
28+
font-size: x-large;
29+
padding: 4px 10px;
30+
31+
}
532
}
33+
34+

0 commit comments

Comments
 (0)