Skip to content

Commit 9b6a71d

Browse files
Create Banner component and examples
1 parent 9793e46 commit 9b6a71d

File tree

4 files changed

+156
-2
lines changed

4 files changed

+156
-2
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import React from 'react';
2+
3+
import { Banner } from './Banner';
4+
import { Stack } from '../Stack';
5+
import { Text } from '../Text';
6+
import { Button } from '../Button';
7+
import { Icon } from '../Icon';
8+
import { Grid, Column } from '../Grid';
9+
10+
export default {
11+
title: 'components/facelift/Banner',
12+
component: Banner,
13+
};
14+
15+
export const WithDismiss = () => (
16+
<Banner onDismiss={() => {}}>
17+
You are no longer in a Pro team. This private repo is in view mode only.
18+
Make it public or upgrade.
19+
</Banner>
20+
);
21+
22+
export const WithoutDismiss = () => (
23+
<Banner>
24+
You are no longer in a Pro team. This private repo is in view mode only.
25+
Make it public or upgrade.
26+
</Banner>
27+
);
28+
29+
export const ExampleUsage = () => (
30+
<Banner onDismiss={() => {}}>
31+
<Stack gap={2} justify="space-between">
32+
<Stack direction="vertical" gap={8} justify="space-between">
33+
<Text fontFamily="everett" size={24}>
34+
<Text color="#EDFFA5" weight="600" block>
35+
Upgrade to <Text css={{ textTransform: 'uppercase' }}>pro</Text>
36+
</Text>
37+
<Text block>Enjoy the full CodeSandbox experience.</Text>
38+
</Text>
39+
<Button autoWidth>Learn more</Button>
40+
</Stack>
41+
<Stack align="flex-end">
42+
<Grid
43+
as="ul"
44+
columnGap={3}
45+
rowGap={3}
46+
css={{
47+
color: '#EBEBEB',
48+
margin: 0,
49+
padding: 0,
50+
listStyleType: 'none',
51+
}}
52+
>
53+
<Column as="li" span={6}>
54+
<Stack gap={4}>
55+
<Icon name="profile" />
56+
<Text size={13} lineHeight="16px">
57+
Up to 20 editors
58+
</Text>
59+
</Stack>
60+
</Column>
61+
<Column as="li" span={6}>
62+
<Stack gap={4}>
63+
<Icon name="profile" />
64+
<Text size={13} lineHeight="16px">
65+
Private NPM packages
66+
</Text>
67+
</Stack>
68+
</Column>
69+
<Column as="li" span={6}>
70+
<Stack gap={4}>
71+
<Icon name="profile" />
72+
<Text size={13} lineHeight="16px">
73+
Unlimited sandboxes
74+
</Text>
75+
</Stack>
76+
</Column>
77+
<Column as="li" span={6}>
78+
<Stack gap={4}>
79+
<Icon name="profile" />
80+
<Text size={13} lineHeight="16px">
81+
Advanced privacy settings
82+
</Text>
83+
</Stack>
84+
</Column>
85+
<Column as="li" span={6}>
86+
<Stack gap={4}>
87+
<Icon name="profile" />
88+
<Text size={13} lineHeight="16px">
89+
Unlimited repositories
90+
</Text>
91+
</Stack>
92+
</Column>
93+
<Column as="li" span={6}>
94+
<Stack gap={4}>
95+
<Icon name="profile" />
96+
<Text size={13} lineHeight="16px">
97+
6GB RAM, 12GB Disk, 4 vCPUs
98+
</Text>
99+
</Stack>
100+
</Column>
101+
</Grid>
102+
</Stack>
103+
</Stack>
104+
</Banner>
105+
);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
3+
import { Element } from '../Element';
4+
import { IconButton } from '../IconButton';
5+
6+
interface BannerProps {
7+
children: React.ReactNode;
8+
onDismiss?: () => void;
9+
}
10+
11+
export const Banner = ({ children, onDismiss }: BannerProps) => {
12+
return (
13+
<Element
14+
css={{
15+
position: 'relative',
16+
padding: [4, 6, 8],
17+
backgroundColor: '#252525',
18+
borderRadius: '4px',
19+
}}
20+
>
21+
{children}
22+
23+
{onDismiss ? (
24+
<Element
25+
css={{ position: 'absolute', right: [1, 2, 4], top: [1, 2, 4] }}
26+
>
27+
<IconButton
28+
name="cross"
29+
variant="round"
30+
title="Dismiss"
31+
onClick={onDismiss}
32+
/>
33+
</Element>
34+
) : null}
35+
</Element>
36+
);
37+
};

packages/components/src/components/Stack/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ export const Stack = styled(Element)<{
99
justify?: React.CSSProperties['justifyContent'];
1010
align?: React.CSSProperties['alignItems'];
1111
inline?: boolean;
12-
}>(({ gap = 0, direction = 'horizontal', justify, align, inline }) =>
12+
wrap?: boolean;
13+
}>(({ gap = 0, direction = 'horizontal', justify, align, inline, wrap }) =>
1314
css({
1415
display: inline ? 'inline-flex' : 'flex',
1516
flexDirection: direction === 'horizontal' ? 'row' : 'column',
1617
justifyContent: justify,
1718
alignItems: align,
19+
flexWrap: wrap ? 'wrap' : 'nowrap',
1820

1921
'> *:not(:last-child)': {
2022
[direction === 'horizontal' ? 'marginRight' : 'marginBottom']: gap,

packages/components/src/components/Text/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const overflowStyles = {
1616
whiteSpace: 'nowrap',
1717
};
1818

19+
const fontFamilies = {
20+
inter: 'Inter, sans-serif',
21+
everett: 'Everett, sans-serif',
22+
};
23+
1924
export interface ITextProps extends React.HTMLAttributes<HTMLSpanElement> {
2025
size?: number;
2126
align?: string;
@@ -26,6 +31,8 @@ export interface ITextProps extends React.HTMLAttributes<HTMLSpanElement> {
2631
variant?: 'body' | 'muted' | 'danger' | 'active';
2732
dateTime?: string;
2833
lineHeight?: string;
34+
color?: string;
35+
fontFamily?: 'inter' | 'everett';
2936
}
3037

3138
export const Text = styled(Element).attrs(p => ({
@@ -40,6 +47,8 @@ export const Text = styled(Element).attrs(p => ({
4047
variant = 'body',
4148
maxWidth,
4249
lineHeight,
50+
color,
51+
fontFamily,
4352
...props
4453
}) =>
4554
css({
@@ -49,8 +58,9 @@ export const Text = styled(Element).attrs(p => ({
4958
lineHeight: lineHeight || 'normal',
5059
fontStyle: fontStyle || null, // from theme.fontWeights
5160
display: block || maxWidth ? 'block' : 'inline',
52-
color: variants[variant],
61+
color: color || variants[variant],
5362
maxWidth,
63+
fontFamily: fontFamilies[fontFamily],
5464
...(maxWidth ? overflowStyles : {}),
5565
})
5666
);

0 commit comments

Comments
 (0)