Skip to content

Commit 61aca91

Browse files
authored
feat: Tiny and Mini Button variations (#298)
1 parent 074d7d7 commit 61aca91

32 files changed

+119
-42
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

packages/fuselage/src/components/Button/ActionButton.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,20 @@ import React from 'react';
33
import { Button } from '.';
44
import { Icon } from '../Icon';
55

6-
export const ActionButton = ({ icon, ...props }) => <Button {...props} square small flexShrink={0}><Icon name={icon} size='x20'/></Button>;
6+
const getSize = ({ tiny, mini, small }) => {
7+
if (mini) {
8+
return 'x16';
9+
}
10+
11+
if (tiny) {
12+
return 'x20';
13+
}
14+
15+
if (small) {
16+
return 'x24';
17+
}
18+
19+
return 'x20';
20+
};
21+
22+
export const ActionButton = React.forwardRef(({ icon, ...props }, ref) => <Button ref={ref} square flexShrink={0} {...props}><Icon name={icon} size={getSize(props)}/></Button>);

packages/fuselage/src/components/Button/Button.stories.mdx

+39-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Indicates an actionable user action.
121121
common={{ small: true, onClick: action('click') }}
122122
xAxis={{
123123
text: { children: 'Button' },
124-
'square + icon': { square: true, children: <Icon name='circled-arrow-down' size='x16' /> },
124+
'square + icon': { square: true, children: <Icon name='circled-arrow-down' size='x20' /> },
125125
'text + icon': { children: <><Icon name='circled-arrow-down' size='x12' /> Button</> },
126126
'text + icon + danger': { children: <><Icon name='circled-arrow-down' size='x12' /> Button</>, danger: true },
127127
'text + icon + success': { children: <><Icon name='circled-arrow-down' size='x12' /> Button</>, success: true },
@@ -136,6 +136,44 @@ Indicates an actionable user action.
136136
/>
137137
</Story>
138138

139+
#### Tiny
140+
141+
<Story name='States of Tiny Variant'>
142+
<PropsVariationSection
143+
component={Button}
144+
common={{ tiny: true, onClick: action('click') }}
145+
xAxis={{
146+
'square + icon': { square: true, children: <Icon name='circled-arrow-down' size='x20' /> },
147+
}}
148+
yAxis={{
149+
default: {},
150+
hover: { className: 'hover' },
151+
active: { className: 'active' },
152+
focus: { className: 'focus focus-visible' },
153+
disabled: { disabled: true },
154+
}}
155+
/>
156+
</Story>
157+
158+
#### Tiny
159+
160+
<Story name='States of Mini Variant'>
161+
<PropsVariationSection
162+
component={Button}
163+
common={{ mini: true, onClick: action('click') }}
164+
xAxis={{
165+
'square + icon': { square: true, children: <Icon name='circled-arrow-down' size='x16' /> },
166+
}}
167+
yAxis={{
168+
default: {},
169+
hover: { className: 'hover' },
170+
active: { className: 'active' },
171+
focus: { className: 'focus focus-visible' },
172+
disabled: { disabled: true },
173+
}}
174+
/>
175+
</Story>
176+
139177
### Primary
140178

141179
<Story name='States Of Primary Variant'>

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

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const Button = forwardRef(function Button({
1212
primary,
1313
rel,
1414
small,
15+
tiny,
16+
mini,
1517
square,
1618
...props
1719
}, ref) {
@@ -38,6 +40,8 @@ export const Button = forwardRef(function Button({
3840
rcx-button--small={small}
3941
rcx-button--square={square}
4042
rcx-button--small-square={small && square}
43+
rcx-button--tiny-square={tiny && square}
44+
rcx-button--mini-square={mini && square}
4145
ref={ref}
4246
{...extraProps}
4347
{...props}

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

+15
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@
7878
@include with-squared-size(
7979
$size: lengths.size(40),
8080
);
81+
display: flex;
82+
justify-content: center;
83+
align-items: center;
84+
}
85+
86+
&--tiny-square {
87+
@include with-squared-size(
88+
$size: lengths.size(24),
89+
);
90+
}
91+
92+
&--mini-square {
93+
@include with-squared-size(
94+
$size: lengths.size(20),
95+
);
8196
}
8297

8398
&--small-square {

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React, { useRef, useCallback } from 'react';
22

33
import {
4-
Button,
4+
ActionButton,
55
PositionAnimated,
66
Options,
7-
Icon,
87
useCursor,
98
} from '..';
109

@@ -15,6 +14,9 @@ const menuAction = ([selected], options) => {
1514
const mapOptions = (options) => Object.entries(options).map(([value, { label }]) => [value, label]);
1615

1716
export const Menu = ({
17+
tiny,
18+
mini,
19+
small = tiny || mini ? null : true,
1820
options,
1921
optionWidth,
2022
placement = 'bottom-start',
@@ -41,18 +43,19 @@ export const Menu = ({
4143

4244
return (
4345
<>
44-
<Button
46+
<ActionButton
4547
ref={ref}
46-
small
4748
ghost
49+
small={small}
50+
tiny={tiny}
51+
mini={mini}
4852
onClick={onClick}
4953
onBlur={hide}
5054
onKeyUp={handleKeyUp}
5155
onKeyDown={handleKeyDown}
56+
icon='kebab'
5257
{...props}
53-
>
54-
<Icon name='kebab' size={20} />
55-
</Button>
58+
/>
5659
<PositionAnimated
5760
width='auto'
5861
visible={visible}

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import { Icon as FuselageIcon, ButtonGroup } from '../..';
3+
import { Icon as FuselageIcon, ButtonGroup, ActionButton } from '../..';
44

55
const Item = ({ selected, highlighted, clickable, is: Tag = 'div', ...props }) => <Tag
66
className={[
@@ -30,6 +30,8 @@ const Avatar = (props) => <Container><div className='rc-box rcx-box--full rcx-si
3030

3131
const Actions = (props) => <ButtonGroup small {...props}/>;
3232

33+
const Action = (props) => <ActionButton small {...props}/>;
34+
3335
Object.assign(Item, {
3436
Menu,
3537
Container,
@@ -41,6 +43,7 @@ Object.assign(Item, {
4143
Icon,
4244
Avatar,
4345
Actions,
46+
Action,
4447
});
4548

4649
export default Item;

packages/fuselage/src/components/Sidebar/Item.stories.mdx

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta, Canvas, Story } from '@storybook/addon-docs/blocks';
22

3-
import { ActionButton, Avatar } from '../..';
3+
import { Avatar } from '../..';
44
import Item from './Item';
55

66
<Meta title='Sidebar/Item' parameters={{ jest: ['Sidebar/spec'] }} />
@@ -19,10 +19,10 @@ Item component to be used inside Sidebar.
1919
</Item.Content>
2020
<Item.Container>
2121
<Item.Actions>
22-
<ActionButton primary success icon='phone'/>
23-
<ActionButton primary danger icon='circle-cross'/>
24-
<ActionButton primary icon='trash'/>
25-
<ActionButton icon='phone'/>
22+
<Item.Action primary success icon='phone'/>
23+
<Item.Action primary danger icon='circle-cross'/>
24+
<Item.Action primary icon='trash'/>
25+
<Item.Action icon='phone'/>
2626
</Item.Actions>
2727
</Item.Container>
2828
</Item>
@@ -34,10 +34,10 @@ Item component to be used inside Sidebar.
3434
</Item.Content>
3535
<Item.Container>
3636
<Item.Actions>
37-
<ActionButton primary success icon='phone'/>
38-
<ActionButton primary danger icon='circle-cross'/>
39-
<ActionButton primary icon='trash'/>
40-
<ActionButton icon='phone'/>
37+
<Item.Action primary success icon='phone'/>
38+
<Item.Action primary danger icon='circle-cross'/>
39+
<Item.Action primary icon='trash'/>
40+
<Item.Action icon='phone'/>
4141
</Item.Actions>
4242
</Item.Container>
4343
</Item>
@@ -54,10 +54,10 @@ Item component to be used inside Sidebar.
5454
</Item.Content>
5555
<Item.Container>
5656
<Item.Actions>
57-
<ActionButton primary success icon='phone'/>
58-
<ActionButton primary danger icon='circle-cross'/>
59-
<ActionButton primary icon='trash'/>
60-
<ActionButton icon='phone'/>
57+
<Item.Action primary success icon='phone'/>
58+
<Item.Action primary danger icon='circle-cross'/>
59+
<Item.Action primary icon='trash'/>
60+
<Item.Action icon='phone'/>
6161
</Item.Actions>
6262
</Item.Container>
6363
</Item>

packages/fuselage/src/components/Sidebar/Sidebar.stories.mdx

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Meta, Canvas, Story } from '@storybook/addon-docs/blocks';
22

33
import Sidebar from '.';
4-
import { ActionButton, Avatar } from '../..';
4+
import { Avatar } from '../..';
55

66
<Meta title='Sidebar' parameters={{ jest: ['Sidebar/spec'] }} />
77

@@ -35,10 +35,10 @@ import { ActionButton, Avatar } from '../..';
3535
</Sidebar.Item.Content>
3636
<Sidebar.Item.Container>
3737
<Sidebar.Item.Actions>
38-
<ActionButton primary success icon='phone'/>
39-
<ActionButton primary danger icon='circle-cross'/>
40-
<ActionButton primary icon='trash'/>
41-
<ActionButton icon='phone'/>
38+
<Sidebar.Item.Action primary success icon='phone'/>
39+
<Sidebar.Item.Action primary danger icon='circle-cross'/>
40+
<Sidebar.Item.Action primary icon='trash'/>
41+
<Sidebar.Item.Action icon='phone'/>
4242
</Sidebar.Item.Actions>
4343
</Sidebar.Item.Container>
4444
</Sidebar.Item>
@@ -50,10 +50,10 @@ import { ActionButton, Avatar } from '../..';
5050
</Sidebar.Item.Content>
5151
<Sidebar.Item.Container>
5252
<Sidebar.Item.Actions>
53-
<ActionButton primary success icon='phone'/>
54-
<ActionButton primary danger icon='circle-cross'/>
55-
<ActionButton primary icon='trash'/>
56-
<ActionButton icon='phone'/>
53+
<Sidebar.Item.Action primary success icon='phone'/>
54+
<Sidebar.Item.Action primary danger icon='circle-cross'/>
55+
<Sidebar.Item.Action primary icon='trash'/>
56+
<Sidebar.Item.Action icon='phone'/>
5757
</Sidebar.Item.Actions>
5858
</Sidebar.Item.Container>
5959
</Sidebar.Item>
@@ -70,10 +70,10 @@ import { ActionButton, Avatar } from '../..';
7070
</Sidebar.Item.Content>
7171
<Sidebar.Item.Container>
7272
<Sidebar.Item.Actions>
73-
<ActionButton primary success icon='phone'/>
74-
<ActionButton primary danger icon='circle-cross'/>
75-
<ActionButton primary icon='trash'/>
76-
<ActionButton icon='phone'/>
73+
<Sidebar.Item.Action primary success icon='phone'/>
74+
<Sidebar.Item.Action primary danger icon='circle-cross'/>
75+
<Sidebar.Item.Action primary icon='trash'/>
76+
<Sidebar.Item.Action icon='phone'/>
7777
</Sidebar.Item.Actions>
7878
</Sidebar.Item.Container>
7979
</Sidebar.Item>

packages/fuselage/src/components/Sidebar/TopBar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ TopBar.Section = ({ children, ...props }) =>
2424
TopBar.Wrapper = Wrapper;
2525
TopBar.Avatar = Avatar;
2626
TopBar.Actions = Actions;
27-
TopBar.Action = (props) => <ActionButton ghost {...props}/>;
27+
TopBar.Action = (props) => <ActionButton small ghost {...props}/>;
2828
TopBar.Divider = () => <Divider mbs='neg-x2' mbe={0} />;
2929
TopBar.Title = (props) => <Box rcx-sidebar-top-bar__title fontScale='p2' color='neutral-900' withTruncatedText {...props} />;
3030

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,21 @@ $sidebar-item-color-selected: theme('sidebar-item-color-selected', colors.foregr
144144

145145
&:hover &__menu-wraper,
146146
&:focus-within &__menu-wraper {
147-
width: lengths.size(28);
147+
width: lengths.size(20);
148148

149149
margin-inline: lengths.margin(4);
150150

151151
opacity: 1;
152152
}
153153

154154
&__menu {
155-
position: absolute;
156-
157-
top: 50%;
155+
position: fixed;
158156

159157
transform: translateY(-50%);
160158
}
161159

162160
&__menu-wraper {
163-
position: relative;
161+
position: static;
164162

165163
flex-shrink: 0;
166164

0 commit comments

Comments
 (0)