Skip to content

Commit 7418833

Browse files
authored
feat: Export components used both in Plural app and Console (#523)
1 parent fbdee01 commit 7418833

File tree

10 files changed

+285
-0
lines changed

10 files changed

+285
-0
lines changed

src/components/InfoPanel.tsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { Layer } from 'grommet'
2+
import { Div, Flex, Span } from 'honorable'
3+
4+
import { Card, CloseIcon, IconFrame } from '../index'
5+
6+
export default function InfoPanel({
7+
title,
8+
onClose = () => {},
9+
width = 420,
10+
marginTop = '0',
11+
contentHeight = 300,
12+
contentPadding = 0,
13+
contentGap = 0,
14+
children,
15+
}: {
16+
title: string
17+
onClose?: () => void
18+
width?: number | string
19+
marginTop?: string
20+
contentHeight?: number | string
21+
contentPadding?: number | string
22+
contentGap?: number | string
23+
children?: JSX.Element | JSX.Element[] | string
24+
}) {
25+
return (
26+
<Layer
27+
plain
28+
onClickOutside={onClose}
29+
position="top-right"
30+
margin={{ top: marginTop }}
31+
>
32+
<Card
33+
fillLevel={2}
34+
width={width}
35+
overflow="hidden"
36+
margin="large"
37+
>
38+
<Div
39+
padding="medium"
40+
borderBottom="1px solid border-fill-two"
41+
>
42+
<Flex
43+
align="center"
44+
justify="space-between"
45+
>
46+
<Span
47+
fontSize={18}
48+
fontWeight={500}
49+
lineHeight="24px"
50+
>
51+
{title}
52+
</Span>
53+
<IconFrame
54+
clickable
55+
icon={<CloseIcon />}
56+
onClick={() => onClose()}
57+
/>
58+
</Flex>
59+
</Div>
60+
<Flex
61+
direction="column"
62+
overflowY="auto"
63+
gap={contentGap}
64+
padding={contentPadding}
65+
height={contentHeight}
66+
>
67+
{children}
68+
</Flex>
69+
</Card>
70+
</Layer>
71+
)
72+
}

src/components/Prop.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Div, type DivProps } from 'honorable'
2+
import styled from 'styled-components'
3+
4+
const PropSC = styled.div(({ theme }) => ({
5+
margin: theme.spacing.medium,
6+
7+
'.prop-title': {
8+
...theme.partials.text.caption,
9+
color: theme.colors['text-xlight'],
10+
marginBottom: theme.spacing.xxsmall,
11+
},
12+
}))
13+
14+
export default function Prop({
15+
children,
16+
title,
17+
...props
18+
}: {
19+
title: string
20+
} & DivProps) {
21+
return (
22+
<PropSC>
23+
<div className="prop-title">{title}</div>
24+
<Div {...props}>{children}</Div>
25+
</PropSC>
26+
)
27+
}

src/components/PropWide.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Flex, type FlexProps } from 'honorable'
2+
import styled from 'styled-components'
3+
4+
import { Divider } from '../index'
5+
6+
const PropWideSC = styled.div(({ theme }) => ({
7+
alignItems: 'center',
8+
display: 'flex',
9+
gap: theme.spacing.small,
10+
marginVertical: theme.spacing.small,
11+
12+
'.prop-title': {
13+
...theme.partials.text.overline,
14+
color: theme.colors['text-xlight'],
15+
display: 'flex',
16+
},
17+
}))
18+
19+
export default function PropWide({
20+
children,
21+
title,
22+
...props
23+
}: {
24+
title: string
25+
} & FlexProps) {
26+
return (
27+
<PropWideSC>
28+
<div className="prop-title">{title}</div>
29+
<Divider
30+
backgroundColor="border-fill-three"
31+
flexGrow={1}
32+
/>
33+
<Flex {...props}>{children}</Flex>
34+
</PropWideSC>
35+
)
36+
}

src/components/PropsContainer.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Div, type DivProps } from 'honorable'
2+
import styled from 'styled-components'
3+
4+
const PropsContainerSC = styled(Div)(({ theme }) => ({
5+
border: theme.borders.default,
6+
borderRadius: theme.borderRadiuses.medium,
7+
8+
'.container-title': {
9+
...theme.partials.text.overline,
10+
color: theme.colors['text-xlight'],
11+
margin: theme.spacing.medium,
12+
},
13+
}))
14+
15+
export default function PropsContainer({
16+
children,
17+
title,
18+
...props
19+
}: {
20+
title: string
21+
} & DivProps) {
22+
return (
23+
<PropsContainerSC {...props}>
24+
{title && <div className="container-title">{title}</div>}
25+
{children}
26+
</PropsContainerSC>
27+
)
28+
}

src/components/UserDetails.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import styled from 'styled-components'
2+
3+
import { AppIcon } from '../index'
4+
5+
const UserDetailsSC = styled.div(({ theme }) => ({
6+
alignItems: 'center',
7+
display: 'flex',
8+
gap: theme.spacing.xsmall,
9+
whiteSpace: 'nowrap',
10+
11+
'.name': {
12+
...theme.partials.text.body2,
13+
},
14+
15+
'.email': {
16+
...theme.partials.text.caption,
17+
color: theme.colors['text-xlight'],
18+
display: 'flex',
19+
overflow: 'hidden',
20+
textOverflow: 'ellipsis',
21+
},
22+
}))
23+
24+
export default function UserDetails({
25+
name,
26+
email,
27+
avatar,
28+
}: {
29+
name?: string | null
30+
email?: string | null
31+
avatar?: string | null
32+
}) {
33+
return (
34+
<UserDetailsSC>
35+
<AppIcon
36+
name={name || ''}
37+
url={avatar || undefined}
38+
size="xxsmall"
39+
/>
40+
<div>
41+
<div className="name">{name}</div>
42+
{email && <div className="email">{email}</div>}
43+
</div>
44+
</UserDetailsSC>
45+
)
46+
}

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export type { PageCardProps } from './components/PageCard'
3232
export { default as PageCard } from './components/PageCard'
3333
export { default as PageTitle } from './components/PageTitle'
3434
export { default as ProgressBar } from './components/ProgressBar'
35+
export { default as Prop } from './components/Prop'
36+
export { default as PropWide } from './components/PropWide'
37+
export { default as PropsContainer } from './components/PropsContainer'
38+
export { default as InfoPanel } from './components/InfoPanel'
39+
export { default as UserDetails } from './components/UserDetails'
3540
export { default as Radio } from './components/Radio'
3641
export { default as RadioGroup } from './components/RadioGroup'
3742
export { default as AppIcon } from './components/AppIcon'

src/stories/Prop.stories.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Prop } from '../index'
2+
3+
export default {
4+
title: 'Prop',
5+
component: Prop,
6+
}
7+
8+
function Template() {
9+
return <Prop title="Name">Test</Prop>
10+
}
11+
12+
export const Default = Template.bind({})
13+
Default.args = {}

src/stories/PropWide.stories.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { PropWide } from '../index'
2+
3+
export default {
4+
title: 'Prop Wide',
5+
component: PropWide,
6+
}
7+
8+
function Template() {
9+
return <PropWide title="Name">Test</PropWide>
10+
}
11+
12+
export const Default = Template.bind({})
13+
Default.args = {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Prop, PropsContainer, UserDetails } from '../index'
2+
3+
export default {
4+
title: 'Props Container',
5+
component: PropsContainer,
6+
}
7+
8+
function Template() {
9+
return (
10+
<PropsContainer
11+
title="Metadata"
12+
width={200}
13+
>
14+
<Prop title="Name">Test</Prop>
15+
<Prop title="Date">10 minutes ago</Prop>
16+
<Prop title="Owner">
17+
<UserDetails
18+
name="Test"
19+
20+
/>
21+
</Prop>
22+
</PropsContainer>
23+
)
24+
}
25+
26+
export const Default = Template.bind({})
27+
Default.args = {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { UserDetails } from '../index'
2+
3+
export default {
4+
title: 'User Details',
5+
component: UserDetails,
6+
}
7+
8+
function Template() {
9+
return (
10+
<UserDetails
11+
name="Test"
12+
13+
/>
14+
)
15+
}
16+
17+
export const Default = Template.bind({})
18+
Default.args = {}

0 commit comments

Comments
 (0)