Skip to content

Commit

Permalink
feat(Input): component wrapper added
Browse files Browse the repository at this point in the history
  • Loading branch information
Utzel-Butzel committed Mar 5, 2020
1 parent 63b6786 commit 84d32bb
Show file tree
Hide file tree
Showing 18 changed files with 811 additions and 460 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wfp/ui",
"version": "1.4.1-alpha.17",
"version": "1.4.1-alpha.20",
"description": "WFP UI Kit Next",
"license": "Apache-2",
"main": "lib/index.js",
Expand Down Expand Up @@ -144,21 +144,21 @@
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@storybook/addon-a11y": "^6.0.0-alpha.19",
"@storybook/addon-actions": "^6.0.0-alpha.19",
"@storybook/addon-backgrounds": "^6.0.0-alpha.19",
"@storybook/addon-google-analytics": "^6.0.0-alpha.19",
"@storybook/addon-info": "^6.0.0-alpha.19",
"@storybook/addon-jest": "^6.0.0-alpha.19",
"@storybook/addon-knobs": "^6.0.0-alpha.19",
"@storybook/addon-links": "^6.0.0-alpha.19",
"@storybook/addon-notes": "^6.0.0-alpha.19",
"@storybook/addon-options": "^6.0.0-alpha.19",
"@storybook/addon-storysource": "^6.0.0-alpha.19",
"@storybook/addon-viewport": "^6.0.0-alpha.19",
"@storybook/addons": "^6.0.0-alpha.19",
"@storybook/react": "^6.0.0-alpha.19",
"@storybook/theming": "^6.0.0-alpha.19",
"@storybook/addon-a11y": "^6.0.0-alpha.20",
"@storybook/addon-actions": "^6.0.0-alpha.20",
"@storybook/addon-backgrounds": "^6.0.0-alpha.20",
"@storybook/addon-google-analytics": "^6.0.0-alpha.20",
"@storybook/addon-info": "^6.0.0-alpha.20",
"@storybook/addon-jest": "^6.0.0-alpha.20",
"@storybook/addon-knobs": "^6.0.0-alpha.20",
"@storybook/addon-links": "^6.0.0-alpha.20",
"@storybook/addon-notes": "^6.0.0-alpha.20",
"@storybook/addon-options": "^6.0.0-alpha.20",
"@storybook/addon-storysource": "^6.0.0-alpha.20",
"@storybook/addon-viewport": "^6.0.0-alpha.20",
"@storybook/addons": "^6.0.0-alpha.20",
"@storybook/react": "^6.0.0-alpha.20",
"@storybook/theming": "^6.0.0-alpha.20",
"@tippy.js/react": "^3.1.1",
"@wfp/icons": "^0.0.82",
"add": "^2.0.6",
Expand Down
21 changes: 11 additions & 10 deletions src/components/ContentSwitcher/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@

**ContentSwitcher** manipulates the content shown following an exclusive or “either/or” pattern. It is used to toggle between two or more content sections within the same space on screen. Only one section can be shown at a time.

### Text

Be concise and specific. Titles have a max of two words.

### Default selection
Based on usage, there should be a default selection. The default selection is always the first option in a switcher.

ContentSwitcher is forked from [Carbon Components](https://www.carbondesignsystem.com/components/content-switcher/code)
Based on usage, there should be a default selection. The default selection is always the first option in a switcher.

ContentSwitcher is forked from [Carbon Components](https://www.carbondesignsystem.com/components/content-switcher/code)

### Usage with react

```js
import { ContentSwitcher } from '@wfp/ui';
import { iconAddGlyph } from '@wfp/ui';
import { ContentSwitcher, Switch } from '@wfp/ui';
import { iconAddGlyph } from '@wfp/icons';
```

```js
<ContentSwitcher onChange={onChangeAction}>
<Switch
name="one"
text="First section"
<Switch
name="one"
text="First section"
onClick={onClickAction}
kind="anchor"
href="#"
icon={iconAddGlyph}
icon={iconAddGlyph}
/>
<Switch name="two" text="Second section" />
<Switch name="three" text="Third section" />
</ContentSwitcher>
```
```
8 changes: 8 additions & 0 deletions src/components/Form/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
}
}

.#{$prefix}--form-item--invalid {
.#{$prefix}--form-requirement {
max-height: rem(200px);
display: block;
}
}

// Fix for red ring when input is marked required in Firefox, refs #744
input:not(output):not([data-invalid]):-moz-ui-invalid {
box-shadow: none;
Expand Down Expand Up @@ -176,6 +183,7 @@
input[data-invalid],
textarea[data-invalid],
select[data-invalid],
.#{$prefix}--form-item--invalid,
.#{$prefix}--list-box[data-invalid] {
border-color: $support-01;
//box-shadow: 0 2px 0px 0px $support-01;
Expand Down
10 changes: 8 additions & 2 deletions src/components/FormItem/FormItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';

const FormItem = ({ className, children, ...other }) => {
const classNames = classnames('wfp--form-item', className);
const FormItem = ({ className, children, invalid, ...other }) => {
const classNames = classnames(
'wfp--form-item',
{
'wfp--form-item--invalid': invalid,
},
className
);

return (
<div className={classNames} {...other}>
Expand Down
56 changes: 56 additions & 0 deletions src/components/Input/Input-story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
import Input from '../Input';
import TextInputSkeleton from '../TextInput/TextInput.Skeleton';

const types = {
None: '',
'Text (text)': 'text',
'For email (email)': 'email',
'For password (password)': 'password',
};

const TextInputProps = () => ({
className: 'some-class',
id: 'test2',
defaultValue: text('Default value (defaultValue)', 'This is a default value'),
labelText: text('Label text (labelText)', 'Text Input label'),
placeholder: text('Placeholder text (placeholder)', 'Placeholder text'),
light: boolean('Light variant (light)', false),
disabled: boolean('Disabled (disabled)', false),
hideLabel: boolean('No label (hideLabel)', false),
invalid: boolean('Show form validation UI (invalid)', false),
invalidText: text(
'Form validation UI content (invalidText)',
'A valid value is required'
),
readOnly: boolean('Read-only (readOnly)', false),
helperText: text('Helper text (helperText)', 'Optional helper text.'),
onClick: action('onClick'),
type: select('Form control type (type)', types, 'text'),
onChange: action('onChange'),
});

storiesOf('Components|Input', module)
.addDecorator(withKnobs)
.add('Default', () => (
<Input {...TextInputProps()}>
<input></input>
</Input>
))
.add('Functional', () => (
<Input {...TextInputProps()}>
{props => {
return <input {...props} />;
}}
</Input>
))
.add('skeleton', () => (
<div>
<TextInputSkeleton />
<br />
<TextInputSkeleton hideLabel />
</div>
));
Loading

0 comments on commit 84d32bb

Please sign in to comment.