Skip to content

Commit 2eecec6

Browse files
tassoevanggazzo
authored andcommitted
feat: Scrollable (#98)
* Add Scrollable * Use CSS styles on Margins
1 parent b21cd54 commit 2eecec6

File tree

12 files changed

+102
-136
lines changed

12 files changed

+102
-136
lines changed

packages/fuselage/src/components/Margins/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import PropTypes from 'prop-types';
2+
import { useClassName } from '@rocket.chat/fuselage-hooks';
23

34
import { createStylingComponent } from '../../styles';
4-
import spaces from '../../styles/variables/spaces';
55

66
export const Margins = createStylingComponent(({
77
all,
@@ -12,15 +12,15 @@ export const Margins = createStylingComponent(({
1212
inlineStart,
1313
inlineEnd,
1414
}) => ({
15-
style: {
16-
margin: all && spaces[`x${ all }`],
17-
marginBlock: block && spaces[`x${ block }`],
18-
marginBlockStart: blockStart && spaces[`x${ blockStart }`],
19-
marginBlockEnd: blockEnd && spaces[`x${ blockEnd }`],
20-
marginInline: inline && spaces[`x${ inline }`],
21-
marginInlineStart: inlineStart && spaces[`x${ inlineStart }`],
22-
marginInlineEnd: inlineEnd && spaces[`x${ inlineEnd }`],
23-
},
15+
className: useClassName('rcx-margins', {
16+
all,
17+
block,
18+
blockStart,
19+
blockEnd,
20+
inline,
21+
inlineStart,
22+
inlineEnd,
23+
}),
2424
depth: 1,
2525
}));
2626

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.rcx-margins {
2+
$values: (
3+
2: $spaces-x2,
4+
4: $spaces-x4,
5+
8: $spaces-x8,
6+
12: $spaces-x12,
7+
16: $spaces-x16,
8+
24: $spaces-x24,
9+
32: $spaces-x32,
10+
40: $spaces-x40,
11+
);
12+
13+
@each $value, $spacing in $values {
14+
&--all-#{$value} {
15+
margin: $spacing !important;
16+
}
17+
18+
&--block-#{$value} {
19+
margin-block: $spacing !important;
20+
}
21+
22+
&--block-start-#{$value} {
23+
margin-block-start: $spacing !important;
24+
}
25+
26+
&--block-end-#{$value} {
27+
margin-block-end: $spacing !important;
28+
}
29+
30+
&--inline-#{$value} {
31+
margin-inline: $spacing !important;
32+
}
33+
34+
&--inline-start-#{$value} {
35+
margin-inline-start: $spacing !important;
36+
}
37+
38+
&--inline-end-#{$value} {
39+
margin-inline-end: $spacing !important;
40+
}
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useClassName } from '@rocket.chat/fuselage-hooks';
2+
import PropTypes from 'prop-types';
3+
4+
import { createStylingComponent } from '../../styles';
5+
6+
export const Scrollable = createStylingComponent(({ horizontal, vertical }) => ({
7+
className: useClassName('rcx-scrollable', { horizontal, vertical }),
8+
depth: 1,
9+
}));
10+
11+
Scrollable.displayName = 'Scrollable';
12+
13+
Scrollable.propTypes = {
14+
horizontal: PropTypes.bool,
15+
vertical: PropTypes.bool,
16+
};
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33

4-
import { ScrollableArea } from './index';
5-
4+
import { Scrollable } from '../..';
65

76
it('renders without crashing', () => {
87
const div = document.createElement('div');
9-
ReactDOM.render(<ScrollableArea />, div);
8+
ReactDOM.render(<Scrollable />, div);
109
ReactDOM.unmountComponentAtNode(div);
1110
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';
2+
3+
import { Button, ButtonGroup, Scrollable } from '../..';
4+
5+
<Meta title='Misc|Scrollable' parameters={{ jest: ['Scrollable/spec'] }} />
6+
7+
# Scrollable
8+
9+
Add scroll capability to the wrapped component.
10+
11+
<Props of={Scrollable} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.rcx-scrollable {
2+
@include scrollable;
3+
4+
overflow: auto;
5+
6+
&--horizontal {
7+
overflow: initial;
8+
overflow-x: auto;
9+
}
10+
11+
&--vertical {
12+
overflow: initial;
13+
overflow-y: auto;
14+
}
15+
}

packages/fuselage/src/components/_ScrollableArea/index.js.disabled

-14
This file was deleted.

packages/fuselage/src/components/_ScrollableArea/stories.js.disabled

-57
This file was deleted.

packages/fuselage/src/components/_ScrollableArea/styles.scss.disabled

-49
This file was deleted.

packages/fuselage/src/components/_SideBar/stories.js.disabled

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import centered from '@storybook/addon-centered/react';
22
import { storiesOf } from '@storybook/react';
33
import React from 'react';
44

5-
import { ScrollableArea } from '../ScrollableArea';
5+
import { Scrollable } from '../Scrollable';
66
import { SideBar, SideBarHeader, SideBarMenu, SideBarMenuItem } from './index';
77

88

@@ -13,7 +13,7 @@ storiesOf('Views|SideBar', module)
1313
<SideBar>
1414
<SideBarHeader title='Header title' />
1515

16-
<ScrollableArea>
16+
<Scrollable>
1717
<SideBarMenu>
1818
<SideBarMenuItem>Menu item #1</SideBarMenuItem>
1919
<SideBarMenuItem>Menu item #2</SideBarMenuItem>
@@ -35,6 +35,6 @@ storiesOf('Views|SideBar', module)
3535
<SideBarMenuItem>Menu item #5</SideBarMenuItem>
3636
<SideBarMenuItem>Menu item #6</SideBarMenuItem>
3737
</SideBarMenu>
38-
</ScrollableArea>
38+
</Scrollable>
3939
</SideBar>
4040
));

packages/fuselage/src/components/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export * from './Margins';
1515
export * from './Paragraph';
1616
export * from './PasswordInput';
1717
export * from './RadioButton';
18+
export * from './Scrollable';
1819
export * from './SearchInput';
1920
export * from './SelectInput';
2021
export * from './Subtitle';

packages/fuselage/src/components/index.scss

+2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
@import './Icon/styles.scss';
1111
@import './InputBox/styles.scss';
1212
@import './Label/styles.scss';
13+
@import './Margins/styles.scss';
1314
@import './Paragraph/styles.scss';
1415
@import './Subtitle/styles.scss';
1516
@import './RadioButton/styles.scss';
17+
@import './Scrollable/styles.scss';
1618
@import './Text/styles.scss';
1719
@import './Tile/styles.scss';
1820
@import './ToggleSwitch/styles.scss';

0 commit comments

Comments
 (0)