Skip to content

Commit b95c96a

Browse files
committed
✨ feat: granular paper borders
1 parent 37a0e45 commit b95c96a

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed

src/components/Paper/Paper.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { cx } from '@emotion/css';
22
import React from 'react';
3-
import { AccentColor, SequentialVariant, StateColor, ThemeProps } from '../../types';
3+
import { AccentColor, Orientation, SequentialVariant, SimplePosition, StateColor, ThemeProps } from '../../types';
44
import { useAccessibility } from '../../context/Accessibility/useAccessibility';
55
import { useThemeId } from '../../context/Theme';
66
import styles from './styles/Paper.module.css';
77

88
export type PaperProps = React.HTMLAttributes<HTMLDivElement> &
99
Omit<ThemeProps, 'contrast'> & {
10-
bordered?: boolean;
10+
bordered?: boolean | Array<SimplePosition | Orientation>;
1111
children: React.ReactChild | React.ReactFragment;
1212
className?: string;
1313
color?: StateColor | SequentialVariant | AccentColor | 'contrast' | 'transparent' | 'extreme';
@@ -61,7 +61,8 @@ export const Paper = React.forwardRef<HTMLDivElement, PaperProps>(
6161
<div
6262
className={cx(
6363
styles.paper,
64-
bordered && styles['paper--bordered'],
64+
bordered === true && styles['paper--bordered'],
65+
Array.isArray(bordered) && bordered.map(border => styles[`paper--bordered-${border}`]),
6566
color && styles[`paper--${color}`],
6667
contained && styles['paper--contained'],
6768
container && styles[`paper--${container}`],

src/components/Paper/stories/Paper.stories.tsx

+63
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,66 @@ ContainedLayout.args = {
346346
container: 'panel',
347347
contained: true,
348348
};
349+
350+
export const LeftBorder = Template.bind({});
351+
LeftBorder.decorators = layoutDecorators;
352+
LeftBorder.storyName = 'Border: Left';
353+
LeftBorder.args = {
354+
...defaultArgs,
355+
bordered: ['left'],
356+
color: 'primary',
357+
};
358+
359+
export const RightBorder = Template.bind({});
360+
RightBorder.decorators = layoutDecorators;
361+
RightBorder.storyName = 'Border: Right';
362+
RightBorder.args = {
363+
...defaultArgs,
364+
bordered: ['right'],
365+
color: 'primary',
366+
};
367+
368+
export const TopBorder = Template.bind({});
369+
TopBorder.decorators = layoutDecorators;
370+
TopBorder.storyName = 'Border: Top';
371+
TopBorder.args = {
372+
...defaultArgs,
373+
bordered: ['top'],
374+
color: 'primary',
375+
};
376+
377+
export const BottomBorder = Template.bind({});
378+
BottomBorder.decorators = layoutDecorators;
379+
BottomBorder.storyName = 'Border: Bottom';
380+
BottomBorder.args = {
381+
...defaultArgs,
382+
bordered: ['bottom'],
383+
color: 'primary',
384+
};
385+
386+
export const VerticalBorder = Template.bind({});
387+
VerticalBorder.decorators = layoutDecorators;
388+
VerticalBorder.storyName = 'Borders: Vertical';
389+
VerticalBorder.args = {
390+
...defaultArgs,
391+
bordered: ['vertical'],
392+
color: 'primary',
393+
};
394+
395+
export const HorizontalBorder = Template.bind({});
396+
HorizontalBorder.decorators = layoutDecorators;
397+
HorizontalBorder.storyName = 'Borders: Horizontal';
398+
HorizontalBorder.args = {
399+
...defaultArgs,
400+
bordered: ['horizontal'],
401+
color: 'primary',
402+
};
403+
404+
export const BottomLeftBorder = Template.bind({});
405+
BottomLeftBorder.decorators = layoutDecorators;
406+
BottomLeftBorder.storyName = 'Borders: Bottom left';
407+
BottomLeftBorder.args = {
408+
...defaultArgs,
409+
bordered: ['bottom', 'left'],
410+
color: 'primary',
411+
};

src/components/Paper/styles/Paper.module.css

+25
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.paper {
44
background-color: var(--paper-background-color);
55
border-color: var(--paper-border-color);
6+
border-width: 0;
67
color: var(--paper-text-color);
78
position: relative;
89
}
@@ -56,6 +57,30 @@
5657
border-style: solid;
5758
}
5859

60+
.paper--bordered-left,
61+
.paper--bordered-vertical {
62+
border-left-width: 1px;
63+
border-style: solid;
64+
}
65+
66+
.paper--bordered-right,
67+
.paper--bordered-vertical {
68+
border-right-width: 1px;
69+
border-style: solid;
70+
}
71+
72+
.paper--bordered-top,
73+
.paper--bordered-horizontal {
74+
border-top-width: 1px;
75+
border-style: solid;
76+
}
77+
78+
.paper--bordered-bottom,
79+
.paper--bordered-horizontal {
80+
border-bottom-width: 1px;
81+
border-style: solid;
82+
}
83+
5984
.paper--narrowPage {
6085
padding: 20px 70px;
6186

0 commit comments

Comments
 (0)