diff --git a/CHANGELOG.md b/CHANGELOG.md index f0202439a63..617cac92363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added horizontal steps component ([#375](https://github.com/elastic/eui/pull/375)) - Changed look and feel of pagination. Added compressed prop for smaller footprint pagination. ([#380](https://github.com/elastic/eui/pull/380)) - Added `EuiBasicTable` as an opinionated, high level component for constructing tables. Its addition deprecates `EuiTableOfRecords` which is still avaiable, but now marked for removal. ([#377](https://github.com/elastic/eui/pull/377)) +- Add styles for `readOnly` states of form controls. ([#391](https://github.com/elastic/eui/pull/391)) **Bug fixes** diff --git a/src-docs/src/views/form/form_controls_readonly.js b/src-docs/src/views/form/form_controls_readonly.js new file mode 100644 index 00000000000..ab2e3a7807a --- /dev/null +++ b/src-docs/src/views/form/form_controls_readonly.js @@ -0,0 +1,39 @@ +import React from 'react'; + +import { + EuiFieldPassword, + EuiFieldText, + EuiFlexGroup, + EuiFlexItem, + EuiFormRow, + EuiButton, +} from '../../../../src/components'; + +export default () => ( +
+ + + + + + + + + + + + + + + Save + + + + +
+); diff --git a/src-docs/src/views/form/form_example.js b/src-docs/src/views/form/form_example.js index 6d311c7810f..773ab6ddc7b 100644 --- a/src-docs/src/views/form/form_example.js +++ b/src-docs/src/views/form/form_example.js @@ -60,6 +60,10 @@ import Loading from './form_controls_loading'; const loadingSource = require('!!raw-loader!./form_controls_loading'); const loadingHtml = renderToHtml(Loading); +import ReadOnly from './form_controls_readonly'; +const readOnlySource = require('!!raw-loader!./form_controls_readonly'); +const readOnlyHtml = renderToHtml(ReadOnly); + export const FormExample = { title: 'Form', sections: [{ @@ -252,6 +256,24 @@ export const FormExample = {

), demo: , + }, { + title: 'Fields can be in a readonly state', + source: [{ + type: GuideSectionTypes.JS, + code: readOnlySource, + }, { + type: GuideSectionTypes.HTML, + code: readOnlyHtml, + }], + text: ( +

+ Add readOnly to almost any field level (text, number) + component to put it in a readonly state. This will just display the content of the + control and remove any interactions. It is especially handy when using inline forms + with non-editable fields. +

+ ), + demo: , }], }; diff --git a/src/components/form/_index.scss b/src/components/form/_index.scss index 224d29b7043..d62e0595218 100644 --- a/src/components/form/_index.scss +++ b/src/components/form/_index.scss @@ -78,6 +78,13 @@ $euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%); background: darken($euiColorLightestShade, 2%); box-shadow: 0 0 0 1px transparentize($euiColorFullShade, .92); } + + &[readOnly] { + cursor: default; + background: transparent; + border-color: transparent; + box-shadow: none; + } } @import 'checkbox/index';