Skip to content

Commit 0830c8f

Browse files
tassoevanggazzo
authored andcommitted
feat: Add InputGroup component (#48)
1 parent e75bd25 commit 0830c8f

13 files changed

+123
-1
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":18,"numPassedTests":18,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":18,"numTotalTests":18,"openHandles":[],"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1565919581530,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617443,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Page/Header/spec.js","startTime":1565919609461,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617468,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/MenuItem/spec.js","startTime":1565919609461,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617514,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/Header/spec.js","startTime":1565919609460,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617588,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/ToggleSwitch/spec.js","startTime":1565919609460,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617742,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/ButtonGroup/spec.js","startTime":1565919609461,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617776,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/ScrollableArea/spec.js","startTime":1565919609461,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919617907,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Drawer/spec.js","startTime":1565919609461,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618165,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Tabs/spec.js","startTime":1565919617666,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618173,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Input/spec.js","startTime":1565919617582,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618394,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/Menu/spec.js","startTime":1565919617608,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618395,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Grid/spec.js","startTime":1565919617876,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618409,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/spec.js","startTime":1565919617628,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618452,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/RadioButton/spec.js","startTime":1565919617802,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618471,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Page/spec.js","startTime":1565919618021,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618531,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Tab/spec.js","startTime":1565919618300,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618636,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Icon/spec.js","startTime":1565919618453,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919618778,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Button/spec.js","startTime":1565919618455,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565919619049,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/CheckBox/spec.js","startTime":1565919618455,"status":"passed","summary":""}],"wasInterrupted":false}
1+
{"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":19,"numPassedTests":19,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":19,"numTotalTests":19,"openHandles":[],"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1565982083177,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982085758,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/ToggleSwitch/spec.js","startTime":1565982084496,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982085822,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/Header/spec.js","startTime":1565982084594,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982085864,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Page/Header/spec.js","startTime":1565982084585,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982085883,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/CheckBox/spec.js","startTime":1565982084642,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086101,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Tab/spec.js","startTime":1565982085960,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086156,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/ButtonGroup/spec.js","startTime":1565982084630,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086441,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Tabs/spec.js","startTime":1565982086133,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086450,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/RadioButton/spec.js","startTime":1565982086175,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086461,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/ScrollableArea/spec.js","startTime":1565982085838,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086468,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/Menu/spec.js","startTime":1565982086109,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086538,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Drawer/spec.js","startTime":1565982084506,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982086877,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/InputGroup/spec.js","startTime":1565982086468,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088043,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/spec.js","startTime":1565982086448,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088227,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Grid/spec.js","startTime":1565982085785,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088502,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Button/spec.js","startTime":1565982086559,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088609,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Page/spec.js","startTime":1565982086484,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088613,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/SideBar/MenuItem/spec.js","startTime":1565982086458,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088647,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Input/spec.js","startTime":1565982084702,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":[],"failureMessages":[],"fullName":"renders without crashing","location":null,"status":"passed","title":"renders without crashing"}],"endTime":1565982088764,"message":"","name":"/home/tasso/Projetos/RocketChat/Rocket.Chat.Fuselage/packages/fuselage/src/components/Icon/spec.js","startTime":1565982086886,"status":"passed","summary":""}],"wasInterrupted":false}

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

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ $default-theme: (
5757
.rcx-input__container {
5858
@include reset;
5959
@include hideable;
60+
@include used-in('../InputGroup/styles.scss');
6061

6162
display: flex;
6263

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
3+
import { useStyle } from '../../hooks/styles';
4+
import styles from './styles.scss';
5+
6+
7+
export const InputGroup = React.forwardRef(function InputGroup({
8+
className,
9+
invisible,
10+
...props
11+
}, ref) {
12+
const inputGroupClassName = useStyle(styles, 'rcx-input-group', {
13+
invisible,
14+
}, className);
15+
16+
return <fieldset className={inputGroupClassName} role='group' ref={ref} {...props}/>;
17+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
4+
import { InputGroup } from './index';
5+
6+
7+
it('renders without crashing', () => {
8+
const div = document.createElement('div');
9+
ReactDOM.render(<InputGroup />, div);
10+
ReactDOM.unmountComponentAtNode(div);
11+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import centered from '@storybook/addon-centered/react';
2+
import { withKnobs } from '@storybook/addon-knobs';
3+
import { storiesOf } from '@storybook/react';
4+
import React from 'react';
5+
import { jsxDecorator } from 'storybook-addon-jsx';
6+
7+
import { Document, TextSection, ShowCaseSection, createPropsFromKnobs } from '../../helpers/storybook';
8+
import { InputGroup } from './index';
9+
import { Input } from '../Input';
10+
11+
12+
storiesOf('Collections|InputGroup', module)
13+
.lokiSkip('InputGroup', () => <Document>
14+
<TextSection>
15+
<h1>InputGroup</h1>
16+
<p>A container for grouping inputs that semantically share a common data context.</p>
17+
</TextSection>
18+
<ShowCaseSection>
19+
<InputGroup>
20+
<Input
21+
type='email'
22+
label='Email'
23+
/>
24+
<Input
25+
type='password'
26+
label='Password'
27+
/>
28+
</InputGroup>
29+
</ShowCaseSection>
30+
</Document>);
31+
32+
const props = createPropsFromKnobs({
33+
hidden: false,
34+
invisible: false,
35+
});
36+
37+
const Inputs = ({ count }) => new Array(count).fill(undefined).map((_, i) =>
38+
<Input key={i} placeholder={String(i + 1)} />
39+
);
40+
41+
storiesOf('Collections|InputGroup', module)
42+
.addDecorator(jsxDecorator)
43+
.addDecorator(withKnobs)
44+
.addDecorator(centered)
45+
.addParameters({ jest: ['spec'] })
46+
.add('default', () =>
47+
<InputGroup {...props()}>
48+
<Inputs count={3} />
49+
</InputGroup>
50+
)
51+
.add('hidden', () =>
52+
<InputGroup {...props({ hidden: true })}>
53+
<Inputs count={3} />
54+
</InputGroup>
55+
)
56+
.add('invisible', () =>
57+
<InputGroup {...props({ invisible: true })}>
58+
<Inputs count={3} />
59+
</InputGroup>
60+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@import '../../helpers/mixins.scss';
2+
@import '../../helpers/theme-var.scss';
3+
@import '../../styles/dimensions.scss';
4+
5+
$name: 'rcx-input-group';
6+
7+
$default-theme: (
8+
'gutter': 1.5rem,
9+
);
10+
11+
.rcx-input-group {
12+
@include reset;
13+
@include hideable;
14+
15+
display: flex;
16+
17+
margin-top: calc(-1 * #{theme-var('gutter')});
18+
19+
transition: all var-dimension('short-transition-duration');
20+
21+
align-items: center;
22+
23+
flex-flow: column nowrap;
24+
justify-content: center;
25+
26+
& > .rcx-input {
27+
flex: 0 0 auto;
28+
29+
margin-top: theme-var('gutter');
30+
}
31+
}

packages/fuselage/src/helpers/mixins.scss

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
margin: 0;
44
padding: 0;
55

6+
border: none;
7+
68
font-weight: normal;
79

810
appearance: none;

0 commit comments

Comments
 (0)