From c8b59aa51e84ad6ae2c50cb8fcdde346e81715d5 Mon Sep 17 00:00:00 2001 From: Kyle Tsang <6854874+kyletsang@users.noreply.github.com> Date: Tue, 21 Dec 2021 22:51:44 -0800 Subject: [PATCH] docs: refactor forms into top level section (#6158) --- www/src/components/SideNav.js | 21 +- www/src/examples/Form/FormControlDisabled.js | 16 + www/src/examples/Form/GridAutoSizingCustom.js | 29 - www/src/pages/components/forms.js | 541 ------------------ www/src/pages/forms/checks-radios.mdx | 98 ++++ www/src/pages/forms/floating-labels.mdx | 75 +++ www/src/pages/forms/form-control.mdx | 79 +++ www/src/pages/forms/form-text.mdx | 45 ++ .../{components => forms}/input-group.mdx | 0 www/src/pages/forms/layout.mdx | 117 ++++ www/src/pages/forms/overview.mdx | 75 +++ www/src/pages/forms/range.mdx | 38 ++ www/src/pages/forms/select.mdx | 40 ++ www/src/pages/forms/validation.mdx | 83 +++ 14 files changed, 685 insertions(+), 572 deletions(-) create mode 100644 www/src/examples/Form/FormControlDisabled.js delete mode 100644 www/src/examples/Form/GridAutoSizingCustom.js delete mode 100644 www/src/pages/components/forms.js create mode 100644 www/src/pages/forms/checks-radios.mdx create mode 100644 www/src/pages/forms/floating-labels.mdx create mode 100644 www/src/pages/forms/form-control.mdx create mode 100644 www/src/pages/forms/form-text.mdx rename www/src/pages/{components => forms}/input-group.mdx (100%) create mode 100644 www/src/pages/forms/layout.mdx create mode 100644 www/src/pages/forms/overview.mdx create mode 100644 www/src/pages/forms/range.mdx create mode 100644 www/src/pages/forms/select.mdx create mode 100644 www/src/pages/forms/validation.mdx diff --git a/www/src/components/SideNav.js b/www/src/components/SideNav.js index f4a3cab10f..2f3c3726d7 100644 --- a/www/src/components/SideNav.js +++ b/www/src/components/SideNav.js @@ -110,6 +110,19 @@ const gettingStarted = [ const layout = ['grid', 'stack']; +const forms = [ + 'overview', + 'form-control', + 'form-text', + 'select', + 'checks-radios', + 'range', + 'input-group', + 'floating-labels', + 'layout', + 'validation', +]; + const components = [ 'alerts', 'accordion', @@ -122,8 +135,6 @@ const components = [ 'close-button', 'dropdowns', 'figures', - 'forms', - 'input-group', 'images', 'list-group', 'modal', @@ -246,6 +257,12 @@ class SideNav extends React.Component { items={layout} path="/layout" /> + + +
+ +; diff --git a/www/src/examples/Form/GridAutoSizingCustom.js b/www/src/examples/Form/GridAutoSizingCustom.js deleted file mode 100644 index bfbba382f1..0000000000 --- a/www/src/examples/Form/GridAutoSizingCustom.js +++ /dev/null @@ -1,29 +0,0 @@ -
- - - - Preference - - - - - - - - - - - - - - - -
; diff --git a/www/src/pages/components/forms.js b/www/src/pages/components/forms.js deleted file mode 100644 index 23ccee3d5a..0000000000 --- a/www/src/pages/components/forms.js +++ /dev/null @@ -1,541 +0,0 @@ -import { graphql } from 'gatsby'; -import Callout from '../../components/Callout'; -import ComponentApi from '../../components/ComponentApi'; -import LinkedHeading from '../../components/LinkedHeading'; -import ReactPlayground from '../../components/ReactPlayground'; -import FormBasic from '../../examples/Form/Basic'; -import FormFloatingBasic from '../../examples/Form/FormFloatingBasic'; -import FormFloatingCustom from '../../examples/Form/FormFloatingCustom'; -import FormFloatingLayout from '../../examples/Form/FormFloatingLayout'; -import FormFloatingSelect from '../../examples/Form/FormFloatingSelect'; -import FormFloatingTextarea from '../../examples/Form/FormFloatingTextarea'; -import Check from '../../examples/Form/Check'; -import CheckApi from '../../examples/Form/CheckApi'; -import CheckInline from '../../examples/Form/CheckInline'; -import ColorPicker from '../../examples/Form/ColorPicker'; -import FormFile from '../../examples/Form/FormFile'; -import FormDisabled from '../../examples/Form/FormDisabled'; -import FormDisabledInputs from '../../examples/Form/FormDisabledInputs'; -import FormGroup from '../../examples/Form/FormGroup'; -import FormText from '../../examples/Form/FormText'; -import FormLabelSizing from '../../examples/Form/FormLabelSizing'; -import GridAutoSizing from '../../examples/Form/GridAutoSizing'; -import GridAutoSizingCustom from '../../examples/Form/GridAutoSizingCustom'; -import GridAutoSizingColMix from '../../examples/Form/GridAutoSizingColMix'; -import GridBasic from '../../examples/Form/GridBasic'; -import GridColSizes from '../../examples/Form/GridColSizes'; -import GridComplex from '../../examples/Form/GridComplex'; -import Horizontal from '../../examples/Form/Horizontal'; -import InputReadOnly from '../../examples/Form/InputReadOnly'; -import FormInputSizes from '../../examples/Form/InputSizes'; -import NoLabels from '../../examples/Form/NoLabels'; -import Plaintext from '../../examples/Form/Plaintext'; -import Switch from '../../examples/Form/Switch'; -import Range from '../../examples/Form/Range'; -import SelectBasic from '../../examples/Form/SelectBasic'; -import SelectSizes from '../../examples/Form/SelectSizes'; -import FormTextControls from '../../examples/Form/TextControls'; -import ValidationFormik from '../../examples/Form/ValidationFormik'; -import ValidationInputGroup from '../../examples/Form/ValidationInputGroup'; -import ValidationNative from '../../examples/Form/ValidationNative'; -import ValidationTooltips from '../../examples/Form/ValidationTooltips'; -import withLayout from '../../withLayout'; - -export default withLayout(function FormControlsSection({ data }) { - return ( - <> - - Forms - -

- The {''} component renders a form control with - Bootstrap styling. The {''} component wraps a - form control with proper spacing, along with support for a label, help - text, and validation state. To ensure accessibility, set{' '} - controlId on {''}, and use{' '} - {''} for the label. -

- -

- The {''} component directly renders the{' '} - {''} or other specified component. If you need to - access the value of an uncontrolled {''}, - attach a ref to it as you would with an uncontrolled input, - then call ReactDOM.findDOMNode(ref) to get the DOM node. - You can then interact with that node as you would with any other - uncontrolled input. -

-

- If your application contains a large number of form groups, we recommend - building a higher-level component encapsulating a complete field group - that renders the label, the control, and any other necessary components. - We don't provide this out-of-the-box, because the composition of those - field groups is too specific to an individual application to admit a - good one-size-fits-all solution. -

- - Form controls - -

- For textual form controls—like inputs and{' '} - textareas—use the FormControl component. - FormControl adds some additional styles for general appearance, focus - state, sizing, and more. -

- - - Sizing - -

- Use size on {''} and{' '} - {''} to change the size of inputs and labels - respectively. -

- - - Readonly - -

- Add the readOnly prop on an input to prevent modification - of the input's value. Read-only inputs appear lighter (just like - disabled inputs), but retain the standard cursor. -

- - - Readonly plain text - -

- If you want to have readonly elements in your form styled as plain text, - use the plaintext prop on FormControls to remove the - default form field styling and preserve the correct margin and padding. -

- - - File input - - - - Color - - - - Checkboxes and Radios - -

- For the non-textual checkbox and radio controls, FormCheck{' '} - provides a single component for both types that adds some additional - styling and improved layout. -

- - Default (stacked) - -

- By default, any number of checkboxes and radios that are immediate - sibling will be vertically stacked and appropriately spaced with - FormCheck. -

- - - Inline - -

- Group checkboxes or radios on the same horizontal row by adding the{' '} - inline prop. -

- - - Without labels - -

- When you render a FormCheck without a label (no children) - some additional styling is applied to keep the inputs from collapsing.{' '} - - Remember to add an aria-label when omitting labels! - -

- - - Customizing FormCheck rendering - -

- When you need tighter control, or want to customize how the{' '} - FormCheck component renders, it may better to use it's - constituent parts directly. -

-

- By provided children to the FormCheck you can - forgo the default rendering and handle it yourself. (You can still - provide an id to the FormCheck or{' '} - FormGroup and have it propagate to the label and input). -

- - - Range - - Create custom {''} controls with - {''}. The track (the background) and thumb (the - value) are both styled to appear the same across browsers. As only Firefox - supports “filling” their track from the left or right of the thumb as a - means to visually indicate progress, we do not currently support it. - - - Select - - - - Sizing - -

- You may also choose from small and large custom selects to match our - similarly sized text inputs. -

- - - Floating labels - -

- Wrap a {''} element in{' '} - {''} to enable floating labels with - Bootstrap’s textual form fields. A placeholder is required - on each {''} as our method of CSS-only - floating labels uses the :placeholder-shown pseudo-element. -

- - - Textareas - -

- By default, {'