From 6bdd1c4c0ea567c45fdecb1e858a99ee5da246ad Mon Sep 17 00:00:00 2001 From: amzrk2 Date: Mon, 13 Apr 2020 19:13:39 +0800 Subject: Initial commit --- assets/sass/@primer/css/forms/README.md | 25 ++ assets/sass/@primer/css/forms/form-control.scss | 259 +++++++++++++++ assets/sass/@primer/css/forms/form-group.scss | 265 +++++++++++++++ assets/sass/@primer/css/forms/form-select.scss | 39 +++ assets/sass/@primer/css/forms/form-validation.scss | 365 +++++++++++++++++++++ assets/sass/@primer/css/forms/index.scss | 7 + assets/sass/@primer/css/forms/input-group.scss | 53 +++ assets/sass/@primer/css/forms/radio-group.scss | 43 +++ 8 files changed, 1056 insertions(+) create mode 100644 assets/sass/@primer/css/forms/README.md create mode 100644 assets/sass/@primer/css/forms/form-control.scss create mode 100644 assets/sass/@primer/css/forms/form-group.scss create mode 100644 assets/sass/@primer/css/forms/form-select.scss create mode 100644 assets/sass/@primer/css/forms/form-validation.scss create mode 100644 assets/sass/@primer/css/forms/index.scss create mode 100644 assets/sass/@primer/css/forms/input-group.scss create mode 100644 assets/sass/@primer/css/forms/radio-group.scss (limited to 'assets/sass/@primer/css/forms') diff --git a/assets/sass/@primer/css/forms/README.md b/assets/sass/@primer/css/forms/README.md new file mode 100644 index 0000000..e092504 --- /dev/null +++ b/assets/sass/@primer/css/forms/README.md @@ -0,0 +1,25 @@ +--- +bundle: "forms" +generated: true +--- + +# Primer CSS: `forms` bundle + +## Usage + +Primer CSS source files are written in [SCSS]. To include this Primer CSS module in your own build, ensure that your `node_modules` directory is listed in your Sass include paths, then import it with: + +```scss +@import "@primer/css/forms/index.scss"; +``` + +## Build + +The `@primer/css` npm package includes a standalone CSS build of this module in `dist/forms.css`. + +## License + +[MIT](https://github.com/primer/css/blob/master/LICENSE) © [GitHub](https://github.com/) + + +[scss]: https://sass-lang.com/documentation/syntax#scss diff --git a/assets/sass/@primer/css/forms/form-control.scss b/assets/sass/@primer/css/forms/form-control.scss new file mode 100644 index 0000000..778f320 --- /dev/null +++ b/assets/sass/@primer/css/forms/form-control.scss @@ -0,0 +1,259 @@ +// Needs refactoring +// stylelint-disable selector-no-qualifying-type, selector-max-compound-selectors +// stylelint-disable selector-max-type +// Base form controls +// +// Overrides for common inputs for easier styling. + +fieldset { + padding: 0; + margin: 0; + border: 0; +} + +label { + font-weight: $font-weight-bold; +} + +.form-control, +.form-select { + min-height: 34px; + // stylelint-disable-next-line primer/spacing + padding: 6px $spacer-2; + font-size: $h4-size; + // stylelint-disable-next-line primer/typography + line-height: 20px; + color: $text-gray-dark; + vertical-align: middle; + background-color: $bg-white; + background-repeat: no-repeat; // Repeat and position set for form states (success, error, etc) + background-position: right 8px center; // For form validation. This keeps images 8px from right and centered vertically. + border: $border-width $border-style $border-gray-dark; + border-radius: $border-radius; + outline: none; + box-shadow: $form-control-shadow; + + &.focus, + &:focus { + // stylelint-disable-next-line primer/borders + border-color: $blue-400; + outline: none; + box-shadow: $form-control-shadow, $btn-input-focus-shadow; + } + + // Ensures inputs don't zoom on mobile but are body-font size on desktop + @include breakpoint(md) { + font-size: $body-font-size; + } +} + +// Inputs with contrast for easy light gray backgrounds against white. +.input-contrast { + background-color: $bg-gray-light; + + &:focus { background-color: $bg-white; } +} + +// Inputs to be used against dark backgrounds. +.input-dark { + color: $text-white; + // stylelint-disable-next-line primer/colors + background-color: $white-fade-15; + border-color: transparent; + + &::placeholder { + color: inherit; + opacity: 0.6; // inceases contrast ratio to 4.52 + } + + &.focus, + &:focus { + // stylelint-disable-next-line primer/borders + border-color: $black-fade-30; + // stylelint-disable-next-line primer/box-shadow + box-shadow: 0 0 0 0.2em rgba($blue-300, 0.4); + } +} + +// Custom styling for HTML5 validation bubbles (WebKit only) +::placeholder { + color: $text-gray-light; +} + +// Mini inputs, to match .minibutton +.input-sm { + min-height: 28px; + // stylelint-disable-next-line primer/spacing + padding-top: 3px; + // stylelint-disable-next-line primer/spacing + padding-bottom: 3px; + font-size: $font-size-small; + // stylelint-disable-next-line primer/typography + line-height: 20px; +} + +// Large inputs +.input-lg { + padding: $spacer-1 10px; + font-size: $h4-size; +} + +// Full-width inputs +.input-block { + display: block; + width: 100%; +} + +// Inputs with monospace text +.input-monospace { + font-family: $mono-font; +} + +// Hide the icon that tries to autofill contact info in webkit +.input-hide-webkit-autofill { + &::-webkit-contacts-auto-fill-button { + position: absolute; + right: 0; + display: none !important; + pointer-events: none; + visibility: hidden; + } +} + +// Checkboxes and Radiobuttons +// +// For checkboxes and radio button selections. +.form-checkbox { + // stylelint-disable-next-line primer/spacing + padding-left: 20px; + // stylelint-disable-next-line primer/spacing + margin: 15px 0; + vertical-align: middle; + + label { + em.highlight { + position: relative; + left: -$spacer-1; + // stylelint-disable-next-line primer/spacing + padding: 2px $spacer-1; + font-style: normal; + // stylelint-disable-next-line primer/colors + background: $yellow-100; + border-radius: $border-radius; + } + } + + input[type=checkbox], + input[type=radio] { + float: left; + // stylelint-disable-next-line primer/spacing + margin: 5px 0 0 -20px; + vertical-align: middle; + } + + .note { + display: block; + margin: 0; + font-size: $font-size-small; + font-weight: $font-weight-normal; + color: $text-gray; + } +} + +.form-checkbox-details { + display: none; +} + +.form-checkbox-details-trigger { + &:checked { + // child of sibling or sibling + ~ * .form-checkbox-details, + ~ .form-checkbox-details { // eslint-disable selector-combinator-space-before + display: block; + } + } +} + +// Field groups +// +// Wrap field groups in `