diff --git a/.storybook/Octicon.js b/.storybook/Octicon.js index 78db485021..339c56b1cd 100644 --- a/.storybook/Octicon.js +++ b/.storybook/Octicon.js @@ -1,12 +1,12 @@ import React from 'react' import {storiesOf} from '@storybook/react' import octicons from 'octicons' -import SVGInline from 'react-svg-inline' -const Octicon = (props) => { +export const Octicon = (props) => { const {name} = props if (name in octicons) { - return + const svg = octicons[name].toSVG(props) + return } else { throw new Error(`No such octicon: "${name}"!`) } diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html index 03d0c82b2d..de95a89c1b 100644 --- a/.storybook/preview-head.html +++ b/.storybook/preview-head.html @@ -1,2 +1,2 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f25b77306..5bc37a386e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Added - New module `primer-subhead`. The Subhead is a simple header with a bottom border. It's designed to be used on settings and configuration pages. +- Importing `.input-group` into `primer-forms` module. ### Removed - Removing `primer-cards` module. diff --git a/modules/primer-forms/index.scss b/modules/primer-forms/index.scss index 540674802d..89a2247f81 100644 --- a/modules/primer-forms/index.scss +++ b/modules/primer-forms/index.scss @@ -3,3 +3,4 @@ @import "./lib/form-select.scss"; @import "./lib/form-group.scss"; @import "./lib/form-validation.scss"; +@import "./lib/input-group.scss"; diff --git a/modules/primer-forms/lib/input-group.scss b/modules/primer-forms/lib/input-group.scss new file mode 100644 index 0000000000..df49498735 --- /dev/null +++ b/modules/primer-forms/lib/input-group.scss @@ -0,0 +1,51 @@ +.input-group { + display: table; + + .form-control { + position: relative; + width: 100%; + + &:focus { + z-index: 2; + } + + + .btn { + margin-left: 0; + } + } + + // For when you want the input group to behave like inline-block. + &.inline { + display: inline-table; + } +} + +.input-group .form-control, +.input-group-button { + display: table-cell; +} + +.input-group-button { + width: 1%; + vertical-align: middle; // Match the inputs +} + +.input-group .form-control:first-child, +.input-group-button:first-child .btn { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +.input-group-button:first-child .btn { + margin-right: -1px; +} + +.input-group .form-control:last-child, +.input-group-button:last-child .btn { + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +.input-group-button:last-child .btn { + margin-left: -1px; +} diff --git a/modules/primer-forms/stories/index.js b/modules/primer-forms/stories/index.js index 9234217e04..6295ffaf41 100644 --- a/modules/primer-forms/stories/index.js +++ b/modules/primer-forms/stories/index.js @@ -1,134 +1,118 @@ import React from 'react' import { storiesOf } from '@storybook/react' +// sub-stories +import inputGroup from './input-group' + storiesOf('Forms', module) -.add('form-control', () => ( -
+ .addDecorator(story => ( +
+ {story()} +
+ )) + .add('form-control', () => ( -
-)) -.add('input-lg', () => ( -
+ )) + .add('input-block', () => ( + + )) + .add('input-group', inputGroup) + .add('input-lg', () => ( -
-)) -.add('input-sm', () => ( -
+ )) + .add('input-sm', () => ( -
-)) -.add('input-block', () => ( -
- -
-)) -.add('input-monospace', () => ( -
+ )) + .add('input-monospace', () => ( -
-)) -.add('form-select', () => ( -
+ )) + .add('form-select', () => ( -
-)) -.add('select-sm', () => ( -
+ )) + .add('select-sm', () => ( -
-)) -.add('radio', () => ( -
+ )) + .add('radio', () => ( -
-)) -.add('checkbox', () => ( -
+ )) + .add('checkbox', () => ( -
-)) -.add('textarea', () => ( -
+ )) + .add('textarea', () => ( -
-)) -.add('form-actions', () => ( -
- - -
-)) -.add('label highlight', () => ( -
-
-
- -
-
-
-)) -.add('form-checkbox-details', () => ( -
- -
-)) -.add('formgroup', () => ( -
-
-
-
-
+ )) + .add('form-actions', () => ( +
+ + +
+ )) + .add('label highlight', () => ( +
+ +
+ )) + .add('form-checkbox-details', () => ( +
+ +
+ )) + .add('form-group', () => ( +
+
+
+
+
-
-
-
- -
-
+
+
+
+ +
+
-
-
-
- -
-
- -)) -.add('form validation', () => ( -
-
+
+
+
+ +
+
+
+ )) + .add('form validation', () => ( +
@@ -140,6 +124,5 @@ storiesOf('Forms', module)
This example input has a warning.
- -
-)) +
+ )) diff --git a/modules/primer-forms/stories/input-group.js b/modules/primer-forms/stories/input-group.js new file mode 100644 index 0000000000..0a8a3e1c03 --- /dev/null +++ b/modules/primer-forms/stories/input-group.js @@ -0,0 +1,18 @@ +import React from 'react' +import {Octicon} from '../../../.storybook/Octicon' + +export default () => ( +
+ + + + +
+) diff --git a/package.json b/package.json index 291d9947b3..be728a7c1c 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "raw-loader": "^0.5.1", "react": "^15.6.1", "react-dom": "^15.6.1", - "react-svg-inline": "^2.0.0", "registry-url": "^3.1.0", "remark": "^8.0.0", "sass-loader": "^6.0.6",