Skip to content

Commit 56fe9cf

Browse files
tassoevanggazzo
authored andcommitted
feat: Pagination component (#103)
1 parent 227df0d commit 56fe9cf

39 files changed

+486
-87
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

packages/fuselage/src/components/Accordion/Item.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import PropTypes from 'prop-types';
33
import React from 'react';
44

55
import { createStyledComponent } from '../../styles';
6-
import { Icon } from '../Icon';
6+
import { Chevron } from '../Chevron';
77
import { ToggleSwitch } from '../ToggleSwitch';
88

99
const ItemContainer = createStyledComponent('rcx-accordion-item', 'section');
1010
const ItemBar = createStyledComponent('rcx-accordion-item__bar');
1111
const ItemTitle = createStyledComponent('rcx-accordion-item__title', 'h1');
1212
const ItemToggleSwitchContainer = createStyledComponent('rcx-accordion-item__toggle-switch');
13-
const ItemIconContainer = createStyledComponent('rcx-accordion-item__icon');
1413
const ItemPanel = createStyledComponent('rcx-accordion-item__panel');
1514

1615
export const Item = React.forwardRef(function Item({
@@ -95,9 +94,7 @@ export const Item = React.forwardRef(function Item({
9594
&& <ItemToggleSwitchContainer>
9695
<ToggleSwitch checked={!disabled} onClick={handleToggleClick} onChange={onToggleEnabled} />
9796
</ItemToggleSwitchContainer>}
98-
<ItemIconContainer mod-flipped={expanded}>
99-
<Icon name={'arrow-down'} x24 />
100-
</ItemIconContainer>
97+
<Chevron size={24} up={expanded} />
10198
</>}
10299
</ItemBar>}
103100
<ItemPanel id={panelId} mod-expanded={panelExpanded} role='region'>

packages/fuselage/src/components/Accordion/styles.scss

+3-11
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666

6767
flex: 1 1 0;
6868

69-
@include subtitle;
70-
@include subtitle-bold;
71-
@include truncate;
69+
@include as-subtitle($bold: true);
70+
@include with-text--ellipsis;
71+
@include with-text--nowrap;
7272
}
7373

7474
.rcx-accordion-item__toggle-switch {
@@ -79,14 +79,6 @@
7979
margin-inline: #{ $sizes-x24 };
8080
}
8181

82-
.rcx-accordion-item__icon {
83-
@include box;
84-
85-
&--flipped {
86-
transform: rotate(-180deg);
87-
}
88-
}
89-
9082
.rcx-accordion-item__panel {
9183
@include box;
9284

packages/fuselage/src/components/Button/styles.scss

+4-5
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
appearance: none;
8383

8484
@include clickable;
85-
@include truncate;
86-
@include paragraph;
87-
@include paragraph-bold;
85+
@include with-text--ellipsis;
86+
@include with-text--nowrap;
87+
@include as-paragraph($bold: true);
8888

8989
@include with-rectangular-size(
9090
$height: $sizes-x40,
@@ -109,8 +109,7 @@
109109
);
110110

111111
&--small {
112-
@include caption;
113-
@include caption-bold;
112+
@include as-caption($bold: true);
114113

115114
@include with-rectangular-size(
116115
$height: $sizes-x32,

packages/fuselage/src/components/Callout/styles.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@
5050
color: #{ $text-colors-default };
5151
flex-flow: column nowrap;
5252

53-
@include caption;
53+
@include as-caption;
5454
}
5555

5656
.rcx-callout__title {
5757
@include box;
5858

59-
@include caption;
60-
@include caption-bold;
59+
@include as-caption($bold: true);
6160

6261
&--has-children {
6362
margin-bottom: #{ $spaces-x4 };
6463
}
6564

66-
@include truncate;
65+
@include with-text--ellipsis;
66+
@include with-text--nowrap;
6767
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import PropTypes from 'prop-types';
2+
import React, { useMemo } from 'react';
3+
4+
import { createStyledComponent } from '../../styles';
5+
import { Icon } from '../Icon';
6+
7+
const Container = createStyledComponent('rcx-chevron', 'span');
8+
9+
export const Chevron = React.forwardRef(function Chevron({
10+
up,
11+
right,
12+
down,
13+
left,
14+
size,
15+
...props
16+
}, ref) {
17+
const children = useMemo(() => <Icon name='arrow-down' size={size} />, [size]);
18+
19+
return <Container
20+
children={children}
21+
ref={ref}
22+
mod-up={up}
23+
mod-right={right}
24+
mod-down={down}
25+
mod-left={left}
26+
{...props}
27+
/>;
28+
});
29+
30+
Chevron.displayName = 'Chevron';
31+
32+
Chevron.propTypes = {
33+
up: PropTypes.bool,
34+
right: PropTypes.bool,
35+
down: PropTypes.bool,
36+
left: PropTypes.bool,
37+
size: PropTypes.number,
38+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
4+
import { Chevron } from '../..';
5+
6+
it('renders without crashing', () => {
7+
const div = document.createElement('div');
8+
ReactDOM.render(<Chevron />, div);
9+
ReactDOM.unmountComponentAtNode(div);
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { Meta, Preview, Props, Story } from '@storybook/addon-docs/blocks';
2+
3+
import sizes from '../../styles/variables/sizes';
4+
import { Chevron } from '../..';
5+
6+
<Meta title='Misc|Chevron' parameters={{ jest: ['Chevron/spec'] }} />
7+
8+
# Chevron
9+
10+
<Preview>
11+
<Story name='Default'>
12+
<Chevron size={40} />
13+
</Story>
14+
</Preview>
15+
16+
<Props of={Chevron} />
17+
18+
## Up
19+
20+
<Preview>
21+
<Story name='Up'>
22+
<Chevron up />
23+
</Story>
24+
</Preview>
25+
26+
## Right
27+
28+
<Preview>
29+
<Story name='Right'>
30+
<Chevron right />
31+
</Story>
32+
</Preview>
33+
34+
## Down
35+
36+
<Preview>
37+
<Story name='Down'>
38+
<Chevron down />
39+
</Story>
40+
</Preview>
41+
42+
## Left
43+
44+
<Preview>
45+
<Story name='Left'>
46+
<Chevron left />
47+
</Story>
48+
</Preview>
49+
50+
## Size
51+
52+
<Preview>
53+
<Story name='Size'>
54+
<div style={{ display: 'flex', alignItems: 'center' }}>
55+
<Chevron size={2} />
56+
<Chevron size={4} />
57+
<Chevron size={8} />
58+
<Chevron size={16} />
59+
<Chevron size={20} />
60+
<Chevron size={24} />
61+
<Chevron size={32} />
62+
<Chevron size={40} />
63+
</div>
64+
</Story>
65+
</Preview>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.rcx-chevron {
2+
@include box;
3+
display: inline-flex;
4+
5+
&--up {
6+
transform: rotate(-180deg);
7+
}
8+
9+
&--down {
10+
transform: rotate(0deg);
11+
}
12+
13+
&--right {
14+
transform: rotate(-90deg);
15+
16+
&:dir(rtl) {
17+
transform: rotate(-270deg);
18+
}
19+
}
20+
21+
&--left {
22+
transform: rotate(-270deg);
23+
24+
&:dir(rtl) {
25+
transform: rotate(-90deg);
26+
}
27+
}
28+
}

packages/fuselage/src/components/Field/styles.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
user-select: text;
3232

33-
@include ellipsis;
33+
@include with-text--ellipsis;
3434
}
3535

3636
.rcx-field__hint {

packages/fuselage/src/components/Headline/styles.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
margin-bottom: $spaces-x16;
77

8-
@include headline;
8+
@include as-headline;
99

1010
color: $text-colors-default;
1111
}

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const Container = createStyledComponent('rcx-icon', 'i');
88

99
export const Icon = React.forwardRef(function Icon({
1010
name,
11+
size,
1112
x44,
1213
x40,
1314
x32,
@@ -23,15 +24,15 @@ export const Icon = React.forwardRef(function Icon({
2324
aria-hidden='true'
2425
children={nameToCharacterMapping[name]}
2526
mod-name={name}
26-
mod-x44={x44}
27-
mod-x40={x40}
28-
mod-x32={x32}
29-
mod-x24={x24}
30-
mod-x20={x20}
31-
mod-x16={x16}
32-
mod-x8={x8}
33-
mod-x4={x4}
34-
mod-x2={x2}
27+
mod-x44={x44 || size === 44}
28+
mod-x40={x40 || size === 40}
29+
mod-x32={x32 || size === 32}
30+
mod-x24={x24 || size === 24}
31+
mod-x20={x20 || size === 20}
32+
mod-x16={x16 || size === 16}
33+
mod-x8={x8 || size === 8}
34+
mod-x4={x4 || size === 4}
35+
mod-x2={x2 || size === 2}
3536
ref={ref}
3637
{...props}
3738
/>;
@@ -41,6 +42,7 @@ Icon.displayName = 'Icon';
4142

4243
Icon.propTypes = {
4344
name: PropTypes.oneOf(Object.keys(nameToCharacterMapping)).isRequired,
45+
size: PropTypes.number,
4446
x44: PropTypes.bool,
4547
x40: PropTypes.bool,
4648
x32: PropTypes.bool,

packages/fuselage/src/components/InputBox/styles.scss

+10-8
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@
218218

219219
background-color: transparent;
220220

221-
@include paragraph;
222-
@include ellipsis;
221+
@include as-paragraph;
222+
@include with-text--ellipsis;
223223

224224
&--type-textarea {
225225
overflow: auto;
@@ -330,17 +330,19 @@
330330

331331
.rcx-input-box__placeholder {
332332
@include box;
333-
@include truncate;
333+
@include with-text--ellipsis;
334+
@include with-text--nowrap;
334335

335-
@include paragraph;
336+
@include as-paragraph;
336337
color: #{ $input-colors-placeholder-color };
337338
}
338339

339340
.rcx-input-box__option {
340341
@include box;
341-
@include truncate;
342+
@include with-text--ellipsis;
343+
@include with-text--nowrap;
342344

343-
@include paragraph;
345+
@include as-paragraph;
344346
color: #{ $input-colors-color };
345347
}
346348

@@ -369,6 +371,6 @@
369371
border-radius: #{ $borders-radius-x2 };
370372
background-color: #{ $input-colors-background-color };
371373

372-
@include paragraph;
373-
@include ellipsis;
374+
@include as-paragraph;
375+
@include with-text--ellipsis;
374376
}

packages/fuselage/src/components/Label/styles.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868

6969
color: #{ $text-colors-default };
7070

71-
@include paragraph;
71+
@include as-paragraph;
7272

73-
@include ellipsis;
73+
@include with-text--ellipsis;
7474

7575
&--disabled {
7676
color: #{ $text-colors-disabled-label };

0 commit comments

Comments
 (0)