diff --git a/src/forms.scss b/src/forms.scss new file mode 100644 index 0000000..0bc3459 --- /dev/null +++ b/src/forms.scss @@ -0,0 +1,163 @@ +@use "palette"; + +form { + display: grid; + width: min(100%, 75ch); + grid-template-columns: max-content min-content 1fr; + + > * { + font-family: 'Manrope', sans-serif; + } + + > label:not(.description) { + grid-column: 1 / 2; + margin-right: 1rem; + place-self: center end; + } + + > label.description { + margin-left: .5rem; + grid-column: 3 / 4; + place-self: center start; + } + + > input, + select, + textarea, + p.hint { + grid-column: 2 / 4; + } + + p.hint { + font-size: .75rem; + margin: 0 .5rem; + } + + input[type="checkbox"], + input[type="radio"] { + grid-column: 2 / 3; + } +} + +input, +textarea { + background-color: palette.$standout; + border: .1rem solid palette.$standout; + margin: .5rem; + padding: .5rem .75rem; + font-family: 'Manrope', sans-serif; + font-size: 1rem; + transition: border-color .3s; + display: block; + + &:hover { + border-color: palette.$primary; + } + + &:active, + &:focus { + border-color: palette.$primary; + outline: .1rem solid palette.$primary; + } + + &::placeholder { + color: palette.$grey600; + } +} + +input[type="checkbox"], +input[type="radio"] { + cursor: pointer; + appearance: none; + height: 1rem; + width: 1rem; + padding: .75rem; + display: block; + + background-color: palette.$standout; + border: .15rem solid palette.$grey200; + border-radius: .5rem; + + position: relative; + + transition: color .3s, background-color .3s, border-color .3s; + + &:checked { + border-color: palette.$primary; + background-color: palette.$primary; + + &::after { + content: '✔'; + font-size: 125%; + + @if lightness(palette.$primary) > 50 { + color: palette.$grey50 + } + + @else { + color: palette.$grey900 + } + + position: absolute; + left: 50%; + top: 50%; + translate: -50% -50%; + transition: translate .3s, + left .3s, + background-color .3s; + } + } +} + +input[type="radio"] { + border-radius: 100%; + + &:checked::after { + content: ''; + + @if lightness(palette.$primary) > 50 { + background-color: palette.$grey50 + } + + @else { + background-color: palette.$grey900 + } + + border-radius: 100%; + width: 80%; + height: 80%; + position: absolute; + } +} + +input[type="checkbox"].switch { + height: 1px; + width: 3rem; + border-radius: 1rem; + + &::after { + content: ''; + background-color: palette.$grey200; + + border-radius: 100%; + height: 80%; + aspect-ratio: 1 / 1; + position: absolute; + top: 50%; + left: .1rem; + translate: 0 -50%; + } + + &:checked::after { + left: calc(100% - .1rem); + translate: -100% -50%; + + @if lightness(palette.$primary) > 50 { + background-color: palette.$grey50 + } + + @else { + background-color: palette.$grey900 + } + } +} \ No newline at end of file diff --git a/src/main.scss b/src/main.scss index 368f6fe..9d4d430 100644 --- a/src/main.scss +++ b/src/main.scss @@ -5,5 +5,6 @@ @use "headings"; @use "text"; @use "buttons"; +@use "forms"; @use "layouts/publishing"; \ No newline at end of file diff --git a/web/pages/forms.njk b/web/pages/forms.njk new file mode 100644 index 0000000..ed53a52 --- /dev/null +++ b/web/pages/forms.njk @@ -0,0 +1,47 @@ +{% extends "templates/publishing.njk" %} + +{% block main %} +