Skip to content

Commit c80f88a

Browse files
author
Kubit
committed
Include scroll styles
1 parent 5f61563 commit c80f88a

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/types/styles/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export enum Styles {
99
POSITION = 'position',
1010
TYPOGRAPHY = 'typography',
1111
POINTER = 'pointer',
12+
SCROLL = 'scroll',
1213
}
1314

1415
export * from './padding';
@@ -25,3 +26,4 @@ export * from './illustration';
2526
export * from './pointer';
2627
export * from './commonStyle';
2728
export * from './wordWrap';
29+
export * from './scroll';

src/types/styles/scroll.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export type ScrollTypes = {
2+
scrollbar_width?: string;
3+
scrollbar_color?: string;
4+
overflow_block?: string;
5+
overflow_inline?: string;
6+
overflow_x?: string;
7+
overflow_y?: string;
8+
overflow?: string;
9+
overflow_clip_margin?: string;
10+
scrollbar_gutter?: string;
11+
scroll_behavior?: string;
12+
scroll_margin?: string;
13+
scroll_padding?: string;
14+
scroll_snap_align?: string;
15+
scroll_snap_stop?: string;
16+
scroll_snap_type?: string;
17+
webkit_scrollbar?: string; // ::-webkit-scrollbar pseudo-element
18+
scroll_container?: string; // scroll container glossary term
19+
scrollbar_aria_role?: string; // scrollbar ARIA role
20+
};

src/utils/getStyles/getStyles.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,63 @@ import {
1212
PaddingTypes,
1313
PointerTypes,
1414
PositionTypes,
15+
ScrollTypes,
1516
TypographyTypes,
1617
WordWrapTypes,
1718
} from '@/types/styles';
1819
import { AnimationType } from '@/types/styles/animation';
1920

21+
/**
22+
* Get scroll styles.
23+
* @param {ScrollTypes} prop - scroll styles
24+
*/
25+
export const getScrollStyles = (prop?: ScrollTypes): CSSProp => {
26+
if (!prop) {
27+
return css``;
28+
}
29+
const {
30+
scrollbar_width,
31+
scrollbar_color,
32+
overflow_block,
33+
overflow_inline,
34+
overflow_x,
35+
overflow_y,
36+
overflow,
37+
overflow_clip_margin,
38+
scrollbar_gutter,
39+
scroll_behavior,
40+
scroll_margin,
41+
scroll_padding,
42+
scroll_snap_align,
43+
scroll_snap_stop,
44+
scroll_snap_type,
45+
webkit_scrollbar,
46+
scroll_container,
47+
scrollbar_aria_role,
48+
} = prop;
49+
50+
return css`
51+
${scrollbar_width && `scrollbar-width: ${scrollbar_width};`}
52+
${scrollbar_color && `scrollbar-color: ${scrollbar_color};`}
53+
${overflow_block && `overflow-block: ${overflow_block};`}
54+
${overflow_inline && `overflow-inline: ${overflow_inline};`}
55+
${overflow_x && `overflow-x: ${overflow_x};`}
56+
${overflow_y && `overflow-y: ${overflow_y};`}
57+
${overflow && `overflow: ${overflow};`}
58+
${overflow_clip_margin && `overflow-clip-margin: ${overflow_clip_margin};`}
59+
${scrollbar_gutter && `scrollbar-gutter: ${scrollbar_gutter};`}
60+
${scroll_behavior && `scroll-behavior: ${scroll_behavior};`}
61+
${scroll_margin && `scroll-margin: ${scroll_margin};`}
62+
${scroll_padding && `scroll-padding: ${scroll_padding};`}
63+
${scroll_snap_align && `scroll-snap-align: ${scroll_snap_align};`}
64+
${scroll_snap_stop && `scroll-snap-stop: ${scroll_snap_stop};`}
65+
${scroll_snap_type && `scroll-snap-type: ${scroll_snap_type};`}
66+
${webkit_scrollbar && `::-webkit-scrollbar: ${webkit_scrollbar};`}
67+
${scroll_container && `scroll-container: ${scroll_container};`}
68+
${scrollbar_aria_role && `scrollbar-aria-role: ${scrollbar_aria_role};`}
69+
`;
70+
};
71+
2072
/**
2173
* Returns the background styles.
2274
* @param {BackgroundTypes} prop - The background properties.
@@ -520,6 +572,7 @@ const getGenericStyles = (styles?: CommonStyleType): CSSProp => {
520572
${getPointerStyles(styles)}
521573
${getWordWrapStyles(styles)}
522574
${getAnimationStyles(styles)}
575+
${getScrollStyles(styles)}
523576
`;
524577
};
525578

0 commit comments

Comments
 (0)