Skip to content

Commit 0df05d0

Browse files
committed
feat(scrollbars): add windows 95 scrollbars
#5
1 parent 67793bb commit 0df05d0

File tree

20 files changed

+166
-51
lines changed

20 files changed

+166
-51
lines changed

src/Checkbox/Checkbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import styled, { css } from 'styled-components';
55
import { createHatchedBackground } from '../common';
66

77
import useControlledOrUncontrolled from '../common/hooks/useControlledOrUncontrolled';
8-
import Cutout from '../Cutout/Cutout';
8+
import { StyledCutout } from '../Cutout/Cutout';
99
import { StyledListItem } from '../ListItem/ListItem';
1010
import {
1111
size,
@@ -22,7 +22,7 @@ const sharedCheckboxStyles = css`
2222
justify-content: space-around;
2323
margin-right: 0.5rem;
2424
`;
25-
const StyledCheckbox = styled(Cutout)`
25+
const StyledCheckbox = styled(StyledCutout)`
2626
${sharedCheckboxStyles}
2727
width: ${size}px;
2828
height: ${size}px;

src/ColorInput/ColorInput.stories.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ const Wrapper = styled.div`
1414
#cutout {
1515
background: ${({ theme }) => theme.canvas};
1616
display: inline-block;
17+
}
18+
.content {
1719
padding: 1rem;
18-
& > span {
19-
margin-left: 1rem;
20+
& > div {
21+
margin: 1rem 0;
22+
}
23+
24+
& > div > span {
2025
margin-right: 0.5rem;
2126
}
2227
}
@@ -43,10 +48,16 @@ Default.story = {
4348

4449
export const Flat = () => (
4550
<Cutout id='cutout'>
46-
<span>enabled: </span>
47-
<ColorInput variant='flat' defaultValue='#00f' />
48-
<span>disabled: </span>
49-
<ColorInput variant='flat' disabled defaultValue='#00f' />
51+
<div className='content'>
52+
<div>
53+
<span>enabled: </span>
54+
<ColorInput variant='flat' defaultValue='#00f' />
55+
</div>
56+
<div>
57+
<span>disabled: </span>
58+
<ColorInput variant='flat' disabled defaultValue='#00f' />
59+
</div>
60+
</div>
5061
</Cutout>
5162
);
5263

src/Cutout/Cutout.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import propTypes from 'prop-types';
33
import styled from 'styled-components';
4-
import { insetShadow } from '../common';
4+
import { insetShadow, createScrollbars } from '../common';
55

6-
const StyledCutout = styled.div`
6+
export const StyledCutout = styled.div`
77
position: relative;
88
box-sizing: border-box;
99
padding: 2px;
@@ -14,7 +14,7 @@ const StyledCutout = styled.div`
1414
border-top-color: ${({ theme }) => theme.borderDark};
1515
border-right-color: ${({ theme }) => theme.borderLightest};
1616
border-bottom-color: ${({ theme }) => theme.borderLightest};
17-
17+
line-height: 1.5;
1818
&:before {
1919
position: absolute;
2020
left: 0;
@@ -35,11 +35,20 @@ const StyledCutout = styled.div`
3535
}
3636
`;
3737

38+
const Content = styled.div`
39+
box-sizing: border-box;
40+
width: 100%;
41+
height: 100%;
42+
padding: 4px;
43+
overflow: auto;
44+
${createScrollbars()}
45+
`;
46+
3847
const Cutout = React.forwardRef(function Cutout(props, ref) {
3948
const { children, ...otherProps } = props;
4049
return (
4150
<StyledCutout ref={ref} {...otherProps}>
42-
{children}
51+
<Content>{children}</Content>
4352
</StyledCutout>
4453
);
4554
});

src/Cutout/Cutout.stories.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ export const Default = () => (
1111
<Window>
1212
<WindowContent>
1313
<Cutout style={{ width: '300px', height: '200px' }}>
14-
<h1
15-
style={{
16-
fontFamily: 'times new roman',
17-
textAlign: 'center',
18-
fontSize: '3rem',
19-
marginTop: '0.5rem'
20-
}}
21-
>
22-
React95
23-
</h1>
14+
<div>
15+
<p style={{ width: 400 }}>
16+
React95 is the best UI library ever created
17+
</p>
18+
<p>React95 is the best UI library ever created</p>
19+
<p>React95 is the best UI library ever created</p>
20+
<p>React95 is the best UI library ever created</p>
21+
<p>React95 is the best UI library ever created</p>
22+
<p>React95 is the best UI library ever created</p>
23+
<p>React95 is the best UI library ever created</p>
24+
<p>React95 is the best UI library ever created</p>
25+
<p>React95 is the best UI library ever created</p>
26+
</div>
2427
</Cutout>
2528
</WindowContent>
2629
</Window>

src/LoadingIndicator/LoadingIndicator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import propTypes from 'prop-types';
33

44
import styled, { keyframes, css } from 'styled-components';
55

6-
import Cutout from '../Cutout/Cutout';
6+
import { StyledCutout } from '../Cutout/Cutout';
77

88
const Wrapper = styled.div`
99
display: inline-block;
1010
height: 15px;
1111
width: 100%;
1212
`;
13-
const ProgressCutout = styled(Cutout)`
13+
const ProgressCutout = styled(StyledCutout)`
1414
width: 100%;
1515
height: 100%;
1616
width: 100%;

src/NumberField/NumberField.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Wrapper = styled.div`
1414
background: ${({ theme }) => theme.canvas};
1515
padding: 2rem;
1616
width: 300px;
17-
& > * {
17+
& > div > * {
1818
margin-bottom: 1rem;
1919
}
2020
}

src/Progress/Progress.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import propTypes from 'prop-types';
33

44
import styled, { css } from 'styled-components';
55

6-
import Cutout from '../Cutout/Cutout';
6+
import { StyledCutout } from '../Cutout/Cutout';
77
import { blockSizes } from '../common/system';
88

99
const Wrapper = styled.div`
1010
display: inline-block;
1111
height: ${blockSizes.md};
1212
width: 100%;
1313
`;
14-
const ProgressCutout = styled(Cutout)`
14+
const ProgressCutout = styled(StyledCutout)`
1515
width: 100%;
1616
height: 100%;
1717
width: 100%;

src/Radio/Radio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import propTypes from 'prop-types';
33

44
import styled, { css } from 'styled-components';
55
import { createFlatBoxStyles } from '../common';
6-
import Cutout from '../Cutout/Cutout';
6+
import { StyledCutout } from '../Cutout/Cutout';
77
import { StyledListItem } from '../ListItem/ListItem';
88

99
import {
@@ -23,7 +23,7 @@ const sharedCheckboxStyles = css`
2323
margin-right: 0.5rem;
2424
`;
2525
// had to overwrite box-shadow for StyledCheckbox since the default made checkbox too dark
26-
const StyledCheckbox = styled(Cutout)`
26+
const StyledCheckbox = styled(StyledCutout)`
2727
${sharedCheckboxStyles}
2828
background: ${({ theme, isDisabled }) =>
2929
isDisabled ? theme.material : theme.canvas};

src/Radio/Radio.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const Wrapper = styled.div`
1919
color: ${({ theme }) => theme.materialText};
2020
padding: 1rem;
2121
width: 300px;
22-
& > p {
22+
& p {
2323
margin-bottom: 2rem;
2424
}
2525
}

src/Select/Select.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,8 @@ const Select = React.forwardRef(function Select(props, ref) {
440440
onKeyDown={handleKeyDown}
441441
ref={dropdownRef}
442442
role='listbox'
443-
shadow={shadow}
444443
style={
445-
menuMaxHeight && { overflow: 'scroll', maxHeight: menuMaxHeight }
444+
menuMaxHeight && { overflow: 'auto', maxHeight: menuMaxHeight }
446445
}
447446
tabIndex={0}
448447
variant={variant}

src/Select/Select.stories.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const options = [
88
{ value: 1, label: '⚡ Pikachu' },
99
{ value: 2, label: '🌿 Bulbasaur' },
1010
{ value: 3, label: '💦 Squirtle' },
11-
{ value: 4, label: '🔥 Charizard' },
11+
{ value: 4, label: '🔥 Mega Charizard Y' },
1212
{ value: 5, label: '🎤 Jigglypuff' },
1313
{ value: 6, label: '🛌🏻 Snorlax' },
1414
{ value: 7, label: '⛰ Geodude' }
@@ -27,7 +27,7 @@ const Wrapper = styled.div`
2727
#default-selects {
2828
width: 200px;
2929
}
30-
#cutout {
30+
#cutout > div {
3131
width: 250px;
3232
padding: 1rem;
3333
background: ${({ theme }) => theme.canvas};
@@ -111,6 +111,7 @@ export const Flat = () => (
111111
onChange={onChange}
112112
options={options}
113113
width='100%'
114+
menuMaxHeight={160}
114115
/>
115116
<Select
116117
variant='flat'
@@ -152,7 +153,6 @@ export const CustomDisplayFormatting = () => (
152153
onChange={onChange}
153154
options={options}
154155
width={220}
155-
menuMaxHeight={100}
156156
/>
157157
);
158158

src/Select/Select.styles.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { StyledButton as Button } from '../Button/Button';
44
import {
55
shadow as commonShadow,
66
createDisabledTextStyles,
7-
createFlatBoxStyles
7+
createFlatBoxStyles,
8+
createScrollbars
89
} from '../common';
910
import { blockSizes } from '../common/system';
10-
import Cutout from '../Cutout/Cutout';
11+
import { StyledCutout } from '../Cutout/Cutout';
1112

1213
const sharedInputContentStyles = css`
1314
box-sizing: border-box;
@@ -56,7 +57,7 @@ const sharedWrapperStyles = css`
5657
cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};
5758
`;
5859

59-
export const StyledSelectWrapper = styled(Cutout)`
60+
export const StyledSelectWrapper = styled(StyledCutout)`
6061
${sharedWrapperStyles}
6162
background: ${({ theme, isDisabled }) =>
6263
isDisabled ? theme.material : theme.canvas};
@@ -170,7 +171,7 @@ export const StyledDropdownMenu = styled.ul`
170171
cursor: default;
171172
z-index: 1;
172173
cursor: pointer;
173-
box-shadow: ${props => (props.shadow ? commonShadow : 'none')};
174+
box-shadow: ${commonShadow};
174175
${({ variant }) =>
175176
variant === 'flat'
176177
? css`
@@ -183,6 +184,7 @@ export const StyledDropdownMenu = styled.ul`
183184
width: calc(100% - 2px);
184185
border: 2px solid ${({ theme }) => theme.borderDarkest};
185186
`}
187+
${({ variant }) => createScrollbars(variant)}
186188
`;
187189

188190
export const StyledDropdownMenuItem = styled.li`

src/Slider/Slider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { clamp, roundValueToStep } from '../common/utils';
1414
import useControlledOrUncontrolled from '../common/hooks/useControlledOrUncontrolled';
1515
import useForkRef from '../common/hooks/useForkRef';
1616
import { useIsFocusVisible } from '../common/hooks/useIsFocusVisible';
17-
import Cutout from '../Cutout/Cutout';
17+
import { StyledCutout } from '../Cutout/Cutout';
1818

1919
function percentToValue(percent, min, max) {
2020
return (max - min) * percent + min;
@@ -135,10 +135,10 @@ const sharedGrooveStyles = () => css`
135135
width: 100%;
136136
`}
137137
`;
138-
const StyledGroove = styled(Cutout)`
138+
const StyledGroove = styled(StyledCutout)`
139139
${sharedGrooveStyles()}
140140
`;
141-
const StyledFlatGroove = styled(Cutout)`
141+
const StyledFlatGroove = styled(StyledCutout)`
142142
${sharedGrooveStyles()}
143143
144144
border-left-color: ${({ theme }) => theme.flatLight};

src/Slider/Slider.stories.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ const Wrapper = styled.div`
1919
}
2020
}
2121
#cutout {
22+
width: 400px;
23+
}
24+
#cutout > div {
2225
background: ${({ theme }) => theme.canvas};
2326
padding: 1rem;
24-
width: 400px;
27+
2528
& > * {
2629
margin-bottom: 2rem;
2730
}

src/Table/Table.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import propTypes from 'prop-types';
33

44
import styled from 'styled-components';
5-
import Cutout from '../Cutout/Cutout';
5+
import { StyledCutout } from '../Cutout/Cutout';
66

77
const StyledTable = styled.table`
88
display: table;
@@ -12,7 +12,7 @@ const StyledTable = styled.table`
1212
font-size: 1rem;
1313
`;
1414

15-
const StyledCutout = styled(Cutout)`
15+
const Wrapper = styled(StyledCutout)`
1616
&:before {
1717
box-shadow: none;
1818
}
@@ -22,11 +22,11 @@ const Table = React.forwardRef(function Table(props, ref) {
2222
const { children, ...otherProps } = props;
2323

2424
return (
25-
<StyledCutout>
25+
<Wrapper>
2626
<StyledTable ref={ref} {...otherProps}>
2727
{children}
2828
</StyledTable>
29-
</StyledCutout>
29+
</Wrapper>
3030
);
3131
});
3232

src/TableBody/TableBody.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const StyledTableBody = styled.tbody`
88
background: ${({ theme }) => theme.canvas};
99
display: table-row-group;
1010
box-shadow: ${insetShadow};
11+
overflow-y: auto;
1112
`;
1213

1314
const TableBody = React.forwardRef(function TableBody(props, ref) {

src/TextField/TextField.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import React from 'react';
22
import propTypes from 'prop-types';
33

44
import styled, { css } from 'styled-components';
5-
import { createDisabledTextStyles, createFlatBoxStyles } from '../common';
5+
import {
6+
createDisabledTextStyles,
7+
createFlatBoxStyles,
8+
createScrollbars
9+
} from '../common';
610
import { blockSizes } from '../common/system';
7-
import Cutout from '../Cutout/Cutout';
11+
import { StyledCutout } from '../Cutout/Cutout';
812

913
const sharedWrapperStyles = css`
1014
display: flex;
@@ -13,7 +17,7 @@ const sharedWrapperStyles = css`
1317
min-height: ${blockSizes.md};
1418
`;
1519

16-
const Wrapper = styled(Cutout).attrs({
20+
const Wrapper = styled(StyledCutout).attrs({
1721
'data-testid': 'variant-default'
1822
})`
1923
${sharedWrapperStyles}
@@ -54,6 +58,7 @@ const StyledTextArea = styled.textarea`
5458
${sharedInputStyles}
5559
padding: 8px;
5660
resize: none;
61+
${({ variant }) => createScrollbars(variant)}
5762
`;
5863

5964
const TextField = React.forwardRef(function TextField(props, ref) {

0 commit comments

Comments
 (0)