Skip to content

Commit 3905d6a

Browse files
Add sdg button cards
1 parent e1715f0 commit 3905d6a

File tree

6 files changed

+161
-29
lines changed

6 files changed

+161
-29
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@undp/design-system-react",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"main": "./dist/index.cjs",
55
"module": "./dist/index.js",
66
"browser": "./dist/index.umd.js",

src/App.tsx

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
1-
import {
2-
Button,
3-
Drawer,
4-
DrawerClose,
5-
DrawerContent,
6-
DrawerDescription,
7-
DrawerFooter,
8-
DrawerHeader,
9-
DrawerTitle,
10-
DrawerTrigger,
11-
} from '@/index';
1+
import { H3, P, A } from 'storybook/internal/components';
2+
123
import './index.css';
134

145
function App() {
156
return (
16-
<Drawer>
17-
<DrawerTrigger>Open</DrawerTrigger>
18-
<DrawerContent>
19-
<DrawerHeader>
20-
<DrawerTitle>Are you absolutely sure?</DrawerTitle>
21-
<DrawerDescription>This action cannot be undone.</DrawerDescription>
22-
</DrawerHeader>
23-
<DrawerFooter>
24-
<Button>Submit</Button>
25-
<DrawerClose>
26-
<Button variant='outline'>Cancel</Button>
27-
</DrawerClose>
28-
</DrawerFooter>
29-
</DrawerContent>
30-
</Drawer>
7+
<div
8+
style={{
9+
height: '90vh',
10+
maxWidth: '712px',
11+
margin: '0 auto',
12+
padding: '2rem',
13+
display: 'flex',
14+
flexDirection: 'column',
15+
justifyContent: 'center',
16+
alignItems: 'center',
17+
}}
18+
>
19+
<img width='56' alt='undp-logo' src='/undp-logo-blue.svg' />
20+
<H3 style={{ textAlign: 'center', paddingTop: '24px' }}>UNDP Design System for React</H3>
21+
<P style={{ textAlign: 'center' }}>
22+
This design system for react, developed by the United Nations Development Programme, offers
23+
various UI components. You can access the documentation{' '}
24+
<A href='https://react.design.undp.org/' target='_blank' rel='noreferrer'>
25+
here
26+
</A>
27+
.
28+
</P>
29+
<P
30+
style={{
31+
textAlign: 'center',
32+
}}
33+
>
34+
For any feedback or inquiries, please feel free to reach out to us at{' '}
35+
<A href='mailto:[email protected]' target='_blank' rel='noreferrer'>
36+
37+
</A>
38+
</P>
39+
</div>
3140
);
3241
}
3342

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from 'react';
2+
3+
import { cn } from '@/lib/utils';
4+
5+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6+
index: string | number;
7+
text: string;
8+
backgroundColor: string;
9+
textColor?: string;
10+
indexClassName?: string;
11+
textClassName?: string;
12+
}
13+
14+
const SDGCardButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
15+
(
16+
{
17+
className,
18+
indexClassName,
19+
backgroundColor,
20+
textClassName,
21+
textColor,
22+
index,
23+
text,
24+
style,
25+
...props
26+
},
27+
ref,
28+
) => {
29+
const Comp = 'button';
30+
return (
31+
<Comp
32+
{...props}
33+
ref={ref}
34+
style={{
35+
...style,
36+
backgroundColor: backgroundColor || 'var(--blue-600)',
37+
cursor:
38+
'url(https://www.undp.org/libraries/undp--design-system-assets/images/arrow-right-white.svg), auto',
39+
}}
40+
className={cn('min-h-[160px] w-full flex items-center', className)}
41+
>
42+
<strong
43+
className={cn('text-[6.875rem] pl-[6.313rem] font-heading', indexClassName)}
44+
style={{ color: textColor || '#fff' }}
45+
>
46+
{index}
47+
</strong>
48+
<h4
49+
className={cn(
50+
'm-0 font-heading p-0 text-[1.875rem] left-[18rem] tracking-[.094rem] absolute uppercase',
51+
textClassName,
52+
)}
53+
style={{ color: textColor || '#fff' }}
54+
>
55+
{text}
56+
</h4>
57+
</Comp>
58+
);
59+
},
60+
);
61+
62+
SDGCardButton.displayName = 'SDGCardButton';
63+
64+
export { SDGCardButton };

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,6 @@ export {
129129
DrawerTrigger,
130130
} from '@/components/ui/drawer';
131131

132+
export { SDGCardButton } from '@/components/ui/sdgCardButton';
133+
132134
export { cn } from '@/lib/utils';
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import type { Meta, StoryObj } from '@storybook/react';
3+
4+
import { SDGCardButton } from '@/index';
5+
6+
type PagePropsAndCustomArgs = React.ComponentProps<typeof SDGCardButton>;
7+
8+
const meta: Meta<PagePropsAndCustomArgs> = {
9+
title: 'Components/SDGCardButton',
10+
component: SDGCardButton,
11+
tags: ['autodocs'],
12+
argTypes: {
13+
backgroundColor: {
14+
control: { type: 'text' },
15+
type: 'string',
16+
defaultValue: { summary: 'var(--blue-600)' },
17+
},
18+
textColor: {
19+
control: { type: 'text' },
20+
type: 'string',
21+
defaultValue: { summary: '#fff' },
22+
},
23+
index: {
24+
control: { type: 'text' },
25+
},
26+
text: {
27+
control: { type: 'text' },
28+
type: 'string',
29+
},
30+
indexClassName: { control: { type: 'text' } },
31+
textClassName: { control: { type: 'text' } },
32+
},
33+
render: ({ ...args }, { globals: { theme, direction, language } }) => {
34+
return (
35+
<div
36+
dir={direction}
37+
className={`p-4 ${theme} ${language} ${
38+
theme === 'dark' ? 'bg-primary-gray-700' : 'bg-primary-white'
39+
}`}
40+
>
41+
<SDGCardButton
42+
{...args}
43+
onClick={d => {
44+
// eslint-disable-next-line no-console
45+
console.log(d);
46+
}}
47+
/>
48+
</div>
49+
);
50+
},
51+
};
52+
53+
export default meta;
54+
55+
type Story = StoryObj<typeof SDGCardButton>;
56+
57+
export const Default: Story = {};

0 commit comments

Comments
 (0)