Skip to content

Commit c8ec466

Browse files
GoldGroove06kotAPIkodiakhq[bot]
authored
BlockQuote color prop with test, docs and storybook (#797)
Co-authored-by: Pranay Kothapalli <pranaykothapalli@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 93f9649 commit c8ec466

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

docs/app/docs/components/blockquote/page.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import codeUsage from "./docs/codeUsage"
1111

1212

1313
const BlockQuoteDocs = () => {
14+
const columns = [
15+
{name: 'Prop', id: 'prop'},
16+
{name: 'Type', id: 'type'},
17+
{name: 'Default', id: 'default'},
18+
{name: 'Description', id: 'description'},
19+
];
20+
21+
const data = [
22+
{prop: 'color', type: 'string', default: 'null', description: 'Accent Color of the quote', id: 'color'},
23+
];
1424
return <div>
1525
<Documentation currentPage={PAGE_NAME} title='BlockQuote' description={`
1626
BlockQuote is used to display a quote.
@@ -33,7 +43,12 @@ const BlockQuoteDocs = () => {
3343

3444
</div>
3545
</Documentation.ComponentHero>
36-
46+
47+
48+
<div className="max-w-screen-md">
49+
<Documentation.Table columns={columns} data={data} />
50+
</div>
51+
3752
</Documentation>
3853
</div>
3954
}

src/components/ui/BlockQuote/BlockQuote.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ export type BlockQuoteProps = {
99
children: React.ReactNode;
1010
customRootClass?: string;
1111
className?: string;
12+
color?:string;
1213
props?: Record<string, any>[]
1314
}
14-
const BlockQuote = ({ children, customRootClass = '', className = '', ...props }: BlockQuoteProps) => {
15+
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', ...props }: BlockQuoteProps) => {
1516
const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME);
1617

17-
return <blockquote className={clsx(rootClass, className)} {...props}>{children}</blockquote>;
18+
const data_attributes: Record<string, string> = {};
19+
20+
if (color) {
21+
data_attributes['data-accent-color'] = color;
22+
}
23+
24+
return <blockquote className={clsx(rootClass, className)} {...props} {...data_attributes}> {children}</blockquote>;
1825
};
1926

2027
BlockQuote.displayName = COMPONENT_NAME;

src/components/ui/BlockQuote/stories/BlockQuote.stories.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default {
1616
render: (args) => <SandboxEditor>
1717
<div >
1818
<div className='flex space-x-2'>
19-
<BlockQuote className='space-x-1'>
19+
<BlockQuote className='space-x-1' {...args}>
2020
<div className='text-gray-950'>{BLOCKQUOTE_TEXT} </div>
2121
</BlockQuote>
2222

@@ -32,3 +32,9 @@ export const All = {
3232
className: ''
3333
}
3434
};
35+
36+
export const Color = {
37+
args: {
38+
color: 'blue'
39+
}
40+
}

src/components/ui/BlockQuote/tests/BlockQuote.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ describe('BlockQuote', () => {
2626
render(<BlockQuote data-testid='block-quote'>BlockQuote</BlockQuote>);
2727
expect(screen.getByTestId('block-quote')).toBeInTheDocument();
2828
});
29+
30+
test('renders BlockQuote component with color', () => {
31+
render(<BlockQuote className='mr-2' color='blue'>BlockQuote</BlockQuote>);
32+
expect(screen.getByText('BlockQuote')).toHaveAttribute('data-accent-color', 'blue');
33+
});
2934
});

0 commit comments

Comments
 (0)