Skip to content

Commit 36215c7

Browse files
committed
create new share modal to replace old one
1 parent ce4d1a0 commit 36215c7

File tree

4 files changed

+576
-1
lines changed

4 files changed

+576
-1
lines changed
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import css from '@styled-system/css';
4+
5+
export const Container = styled.div(
6+
css({
7+
display: 'flex',
8+
fontFamily: 'Inter, sans-serif',
9+
10+
button: { fontFamily: 'body' },
11+
input: { fontFamily: 'body' },
12+
textarea: { fontFamily: 'body' },
13+
select: { fontFamily: 'body' },
14+
})
15+
);
16+
17+
export const Sidebar = styled.div(
18+
css({
19+
backgroundColor: 'grays.500',
20+
color: 'white',
21+
fontSize: 3,
22+
23+
maxWidth: 300, // for development, remove this
24+
height: '100%', // for development, remove this
25+
// overflowY: 'scroll',
26+
})
27+
);
28+
29+
export const Heading = styled.h1(
30+
css({
31+
margin: 0,
32+
marginBottom: 2,
33+
})
34+
);
35+
36+
export const Description = styled.p(
37+
css({
38+
margin: 0,
39+
marginBottom: 4,
40+
})
41+
);
42+
43+
const SectionHeader = styled.button(props =>
44+
css({
45+
display: 'flex',
46+
width: '100%',
47+
alignItems: 'center',
48+
49+
color: '#fff',
50+
fontSize: 3,
51+
fontWeight: 'medium',
52+
paddingY: 4,
53+
paddingX: 2,
54+
background: 'transparent',
55+
56+
border: 'none',
57+
borderBottom: '1px solid',
58+
borderColor: 'grays.700',
59+
cursor: 'pointer',
60+
':hover': {
61+
backgroundColor: 'grays.700',
62+
},
63+
':focus': {
64+
backgroundColor: 'grays.700',
65+
outline: 'none',
66+
},
67+
svg: {
68+
marginRight: 2,
69+
transform: props.open ? null : 'rotate(-90deg)',
70+
transition: 'transform ease-in',
71+
transitionDuration: theme => theme.speeds[3],
72+
},
73+
})
74+
);
75+
76+
const SectionBody = styled.div(props =>
77+
css({
78+
paddingX: 4,
79+
paddingTop: 4,
80+
paddingBottom: 8,
81+
borderBottom: '1px solid',
82+
borderColor: 'grays.800',
83+
...props.css,
84+
})
85+
);
86+
87+
export const OptionDescription = styled.p(css({}));
88+
89+
export const Section = ({ title, children, defaultOpen, ...props }) => {
90+
const [open, isOpen] = React.useState(title ? defaultOpen : true);
91+
92+
return (
93+
<section {...props}>
94+
<SectionHeader open={open} onClick={() => isOpen(!open)}>
95+
<ToggleIcon />
96+
{title}
97+
</SectionHeader>
98+
{open ? <SectionBody>{children}</SectionBody> : null}
99+
</section>
100+
);
101+
};
102+
103+
Section.Body = SectionBody;
104+
105+
export const Input = styled.input(props =>
106+
css({
107+
backgroundColor: 'grays.700',
108+
border: '1px solid',
109+
borderColor: 'grays.800',
110+
color: 'white',
111+
fontSize: 3,
112+
borderRadius: 'small',
113+
paddingX: 2,
114+
115+
width: '100%',
116+
boxSizing: 'border-box', //probably not right
117+
height: 32,
118+
lineHeight: '32px',
119+
120+
fontFamily: props.code ? 'code' : 'body',
121+
122+
':hover': {
123+
backgroundColor: 'grays.800',
124+
},
125+
':focus': {
126+
backgroundColor: 'grays.800',
127+
borderColor: 'grays.800',
128+
outline: 'none',
129+
},
130+
':disabled:hover': {
131+
backgroundColor: 'grays.700',
132+
},
133+
})
134+
);
135+
136+
export const TextArea = styled(Input)(
137+
css({
138+
height: 'auto', // let rows attr take care of height
139+
lineHeight: 1.6,
140+
marginBottom: 2,
141+
})
142+
);
143+
144+
export const Button = styled.button(
145+
css({
146+
width: '100%',
147+
boxSizing: 'border-box',
148+
backgroundColor: 'blues.600',
149+
border: '1px solid',
150+
borderColor: 'blues.600',
151+
color: 'white',
152+
fontSize: 2,
153+
height: 24,
154+
borderRadius: 'medium',
155+
cursor: 'pointer',
156+
':hover': {
157+
backgroundColor: 'blues.500',
158+
borderColor: 'blues.500',
159+
},
160+
':focus': {
161+
outline: 'none',
162+
backgroundColor: 'blues.600',
163+
borderColor: 'blues.500',
164+
},
165+
166+
textDecoration: 'line-through',
167+
})
168+
);
169+
170+
export const Option = styled.label(props =>
171+
css({
172+
justifyContent: 'space-between',
173+
alignItems: 'center',
174+
minHeight: 32,
175+
lineHeight: 1.6,
176+
marginY: 2,
177+
178+
display: props.multiline ? 'block' : 'flex',
179+
input: {
180+
width: props.multiline ? '100%' : 48,
181+
},
182+
183+
opacity: props.disabled ? 0.25 : 1,
184+
})
185+
);
186+
187+
const ToggleIcon = props => (
188+
<svg
189+
width="10"
190+
height="6"
191+
viewBox="0 0 10 6"
192+
fill="none"
193+
xmlns="http://www.w3.org/2000/svg"
194+
{...props}
195+
>
196+
<path
197+
d="M4.50498 6L0.00488229 1.26364e-06L9.00488 4.76837e-07L4.50498 6Z"
198+
fill="currentcolor"
199+
/>
200+
</svg>
201+
);
202+
203+
export const Switch = props => (
204+
<SwitchLabel>
205+
<input
206+
type="checkbox"
207+
disabled={props.disabled}
208+
checked={props.on}
209+
onChange={props.onChange}
210+
/>
211+
<SwitchBase>
212+
<SwitchToggle />
213+
</SwitchBase>
214+
</SwitchLabel>
215+
);
216+
217+
const SwitchBase = styled.span(
218+
css({
219+
display: 'flex',
220+
alignItems: 'center',
221+
position: 'relative',
222+
width: 28,
223+
height: 14,
224+
borderRadius: 'large',
225+
background: '#040404',
226+
})
227+
);
228+
229+
const SwitchToggle = styled.span(
230+
css(theme => ({
231+
background: 'white',
232+
width: 14,
233+
height: 14,
234+
borderRadius: 'round',
235+
position: 'absolute',
236+
left: 0,
237+
transition: 'left ease',
238+
transitionDuration: theme.speeds[3],
239+
}))
240+
);
241+
242+
const SwitchLabel = styled.label(
243+
css({
244+
cursor: 'pointer',
245+
246+
input: {
247+
width: 0,
248+
opacity: 0,
249+
position: 'absolute',
250+
},
251+
252+
// styled-components way of reffering to sc-elements
253+
// but in an object notation, it's a mess not gonna lie.
254+
[`input:checked + ${SwitchBase}`]: {
255+
background: '#5bc266',
256+
},
257+
[`input:checked + ${SwitchBase} ${SwitchToggle}`]: {
258+
left: 14,
259+
},
260+
})
261+
);
262+
263+
export const Preview = styled.div(
264+
css({
265+
padding: 8,
266+
width: '100%',
267+
background: 'white',
268+
iframe: {
269+
width: '100%',
270+
height: 500,
271+
border: 0,
272+
borderRadius: 2,
273+
overflow: 'hidden',
274+
},
275+
})
276+
);

0 commit comments

Comments
 (0)