From 50af7ae33ad75bd2ec53888b37df259859be4b42 Mon Sep 17 00:00:00 2001 From: Dan Remollino Date: Thu, 3 Apr 2025 17:45:27 -0400 Subject: [PATCH] added demo site --- .gitignore | 1 + README.md | 6 +- demo/css/custom_properties.css | 94 +++++++ demo/css/dialog.css | 24 ++ demo/css/fonts.css | 94 +++++++ demo/css/grid.css | 105 +++++++ demo/css/hamburgers.min.css | 7 + demo/css/main.css | 7 + demo/css/reset.css | 114 ++++++++ demo/css/tags.css | 166 +++++++++++ demo/css/utility_classes.css | 56 ++++ demo/index.html | 144 ++++++++++ demo/js/main.js | 2 + demo/js/validation/README.md | 463 +++++++++++++++++++++++++++++++ demo/js/validation/validation.js | 450 ++++++++++++++++++++++++++++++ 15 files changed, 1732 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 demo/css/custom_properties.css create mode 100644 demo/css/dialog.css create mode 100644 demo/css/fonts.css create mode 100644 demo/css/grid.css create mode 100644 demo/css/hamburgers.min.css create mode 100644 demo/css/main.css create mode 100644 demo/css/reset.css create mode 100644 demo/css/tags.css create mode 100644 demo/css/utility_classes.css create mode 100644 demo/index.html create mode 100644 demo/js/main.js create mode 100644 demo/js/validation/README.md create mode 100644 demo/js/validation/validation.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/README.md b/README.md index 165ee51..8922e84 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# Form Validation +# Demo + +A demo of the form validation class can be found [here](https://demos.danremollino.dev/form-validation/). + +# Documentation Importing the `Validation` class queries the current page for `
` elements and disables the default browser [constraint validation](https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation) diff --git a/demo/css/custom_properties.css b/demo/css/custom_properties.css new file mode 100644 index 0000000..91c0b31 --- /dev/null +++ b/demo/css/custom_properties.css @@ -0,0 +1,94 @@ +:root { + + /* ###### ##### ## ##### ###### */ + /* ### ## ## ## ## ## ## ## */ + /* ## ## ## ## ## ## ###### */ + /* ### ## ## ## ## ## ## ## */ + /* ###### ##### ####### ##### ## ## */ + /* + use color-mix() with transparent to add transparency + https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix#adding_transparency + */ + + &[data-color-scheme="light"] { + /* light gray */ + --color-01-l: 90%; + --color-01-a: 0%; + --color-01-b: 0%; + + /* black */ + --color-02-l: 0%; + --color-02-a: 0%; + --color-02-b: 0%; + } + + &[data-color-scheme="dark"] { + /* black */ + --color-01-l: 0%; + --color-01-a: 0%; + --color-01-b: 0%; + + /* light gray */ + --color-02-l: 90%; + --color-02-a: 0%; + --color-02-b: 0%; + } + + + --color-01: oklab(var(--color-01-l) var(--color-01-a) var(--color-01-b)); + --color-01-light: oklab(calc(var(--color-01-l) + 25%) var(--color-01-a) var(--color-01-b)); + --color-01-dark: oklab(calc(var(--color-01-l) - 25%) var(--color-01-a) var(--color-01-b)); + + --color-02: oklab(var(--color-02-l) var(--color-02-a) var(--color-02-b)); + --color-02-light: oklab(calc(var(--color-02-l) + 25%) var(--color-02-a) var(--color-02-b)); + --color-02-dark: oklab(calc(var(--color-02-l) - 25%) var(--color-02-a) var(--color-02-b)); + + --link-color-01: var(--text-color-01); + --link-decoration-01: none; + --link-hover-color-01: var(--text-color-01); + --link-hover-decoration-01: underline; + + --success-color: oklab(60.735% -40.534% 31.334%); + --info-color: oklab(61.465% -23.829% -17.445%); + --warning-color: oklab(82.103% 10.93% 66.106%); + --danger-color: oklab(50.864% 51.073% 25.414%); + + + + + /* ###### ###### ##### ###### ###### ## ## ###### */ + /* ## ## ## ## ## ### ## ### ## ## */ + /* ##### ###### ####### ## ## ## # ## ## ### */ + /* ## ## ## ## ### ## ## ### ## ## */ + /* ###### ## ## ## ###### ###### ## ## ##### */ + + + --space: 1lh; + --eighth-space: calc(var(--space) * .125); + --quarter-space: calc(var(--space) * .25); + --half-space: calc(var(--space) * .5); + --three-quarter-space: calc(var(--space) * .75); + --one-and-quarter-space: calc(var(--space) * 1.25); + --one-and-half-space: calc(var(--space) * 1.5); + --one-and-three-quarter-space: calc(var(--space) * 1.75); + --double-space: calc(var(--space) * 2); + --tripple-space: calc(var(--space) * 3); + + + + + /* ###### ###### ####### ###### ## ## ###### */ + /* ## ## ## ## ### ## ## */ + /* ##### ## # ## ## # ## ## ### */ + /* ## ## ## ## ## ### ## ## */ + /* ###### ###### ####### ###### ## ## ##### */ + + + --site-max-width: 1440px; + + /* grid.css */ + --content-gap: var(--double-space); + --content-padding: clamp(var(--space), 5dvw, var(--tripple-space)); + --site-padding: max(5dvw, 10px); + --max-content-width: calc(var(--site-max-width) - var(--content-padding) * 2); +} diff --git a/demo/css/dialog.css b/demo/css/dialog.css new file mode 100644 index 0000000..0cc1e5e --- /dev/null +++ b/demo/css/dialog.css @@ -0,0 +1,24 @@ +@layer dialog { + [data-open-dialog]:hover { cursor: pointer; } + + dialog { + border: 0; + padding: var(--half-space); + position: relative; + + &::backdrop { + background-color: rgb(0 0 0 / .75); + } + + .close-btn:hover { cursor: pointer; } + + .close-icon { + height: 20px; + inset: var(--quarter-space) var(--quarter-space) auto auto; + position: absolute; + width: 20px; + } + + body:has(&[open]) { overflow: hidden; } + } +} diff --git a/demo/css/fonts.css b/demo/css/fonts.css new file mode 100644 index 0000000..e47de1c --- /dev/null +++ b/demo/css/fonts.css @@ -0,0 +1,94 @@ +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 100; + src: url('../fonts/kommon_grotesk_thin.woff') format('woff'), + url('../fonts/kommon_grotesk_thin.woff2') format('woff2'); +} + + @font-face { + font-family: 'Kommon Grotesk'; + font-weight: 100; + font-style: italic; + src: url('../fonts/kommon_grotesk_thin_italic.woff') format('woff'), + url('../fonts/kommon_grotesk_thin_italic.woff2') format('woff2'); + } + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 200; + src: url('../fonts/kommon_grotesk_extra_light.woff') format('woff'), + url('../fonts/kommon_grotesk_extra_light.woff2') format('woff2'); +} + + @font-face { + font-family: 'Kommon Grotesk'; + font-weight: 200; + font-style: italic; + src: url('../fonts/kommon_grotesk_extra_light_italic.woff') format('woff'), + url('../fonts/kommon_grotesk_extra_light_italic.woff2') format('woff2'); + } + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 300; + src: url('../fonts/kommon_grotesk_light.woff') format('woff'), + url('../fonts/kommon_grotesk_light.woff2') format('woff2'); +} + + @font-face { + font-family: 'Kommon Grotesk'; + font-weight: 300; + font-style: italic; + src: url('../fonts/kommon_grotesk_light_italic.woff') format('woff'), + url('../fonts/kommon_grotesk_light_italic.woff2') format('woff2'); + } + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 400; + src: url('../fonts/kommon_grotesk_normal.woff') format('woff'), + url('../fonts/kommon_grotesk_normal.woff2') format('woff2'); +} + + @font-face { + font-family: 'Kommon Grotesk'; + font-weight: 400; + font-style: italic; + src: url('../fonts/kommon_grotesk_italic.woff') format('woff'), + url('../fonts/kommon_grotesk_italic.woff2') format('woff2'); + } + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 500; + src: url('../fonts/kommon_grotesk_medium.woff') format('woff'), + url('../fonts/kommon_grotesk_medium.woff2') format('woff2'); +} + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 600; + src: url('../fonts/kommon_grotesk_semi_bold.woff') format('woff'), + url('../fonts/kommon_grotesk_semi_bold.woff2') format('woff2'); +} + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 700; + src: url('../fonts/kommon_grotesk_bold.woff') format('woff'), + url('../fonts/kommon_grotesk_bold.woff2') format('woff2'); +} + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 800; + src: url('../fonts/kommon_grotesk_extra_bold.woff') format('woff'), + url('../fonts/kommon_grotesk_extra_bold.woff2') format('woff2'); +} + +@font-face { + font-family: 'Kommon Grotesk'; + font-weight: 900; + src: url('../fonts/kommon_grotesk_black.woff') format('woff'), + url('../fonts/kommon_grotesk_black.woff2') format('woff2'); +} diff --git a/demo/css/grid.css b/demo/css/grid.css new file mode 100644 index 0000000..1649024 --- /dev/null +++ b/demo/css/grid.css @@ -0,0 +1,105 @@ +/* temp */ +section { + /* background: gray; */ + margin-block: var(--space); +} + +:where(header, section, footer) > * { + background-image: url('https://res.cloudinary.com/demo/image/upload/cashew_chicken.jpg'); + background-size: cover; + color: var(--color-01); + /* text-shadow: 1px 1px 3px var(--color-02); */ +} + +:where(header, section, footer) { + display: grid; + row-gap: var(--content-gap); + grid-template-columns: + [viewport-start] 1fr + [site-padding-start] var(--site-padding) + [content-padding-start] var(--content-padding) + [content-start] + minmax(0, calc(var(--max-content-width) / 12)) + [one-twelfth] + minmax(0, calc(var(--max-content-width) / 12)) + [two-twelfths one-sixth] + minmax(0, calc(var(--max-content-width) / 12)) + [three-twelfths one-fourth fourth one-quarter] + minmax(0, calc(var(--max-content-width) / 12)) + [four-twelfths one-third] + minmax(0, calc(var(--max-content-width) / 12)) + [five-twelfths] + minmax(0, calc(var(--max-content-width) / 12)) + [six-twelfths one-half half] + minmax(0, calc(var(--max-content-width) / 12)) + [seven-twelfths] + minmax(0, calc(var(--max-content-width) / 12)) + [eight-twelfths two-thirds] + minmax(0, calc(var(--max-content-width) / 12)) + [nine-twelfths three-fourths third three-quarters] + minmax(0, calc(var(--max-content-width) / 12)) + [ten-twelfths five-sixths] + minmax(0, calc(var(--max-content-width) / 12)) + [eleven-twelfths] + minmax(0, calc(var(--max-content-width) / 12)) + [content-end twelve-twelfths] + var(--content-padding) [content-padding-end] + var(--site-padding) [site-padding-end] + 1fr [viewport-end]; + + > * { + display: grid; + grid-column: content-padding; + grid-template-columns: subgrid; + padding: var(--content-padding) 0; + + > * { grid-column: content; } + + &.full-viewport { grid-column: viewport !important; } + + &.half-content-left { + grid-column-end: half !important; + padding: var(--content-padding) var(--content-padding) var(--content-padding) 0; + } + &.half-content-right { + grid-column-start: half !important; + padding: var(--content-padding) 0 var(--content-padding) var(--content-padding); + > * { grid-column-start: inherit; } + } + + &.half-viewport-left { + grid-column: viewport-start / half !important; + padding: var(--content-padding) var(--content-padding) var(--content-padding) 0; + } + &.half-viewport-right { + grid-column: half / viewport-end !important; + padding: var(--content-padding) 0 var(--content-padding) var(--content-padding); + > * { grid-column-start: inherit; } + } + + &.remove-padding { + grid-column: content; + padding: 0; + } + + &.remove-inline-padding { + grid-column: content; + padding: var(--content-padding) 0; + } + + @media (max-width: 1240px) { + &[class*="-left"] { grid-column-end: three-quarters !important; } + &[class*="-right"] { grid-column-start: one-quarter !important; } + } + + @media (max-width: 940px) { + &[class*="-left"] { grid-column-end: five-sixths !important; } + &[class*="-right"] { grid-column-start: one-sixth !important; } + } + + @media (max-width: 640px) { + &[class*="-left"] { grid-column-end: content-end !important; } + &[class*="-right"] { grid-column-start: content-start !important; } + } + } +} diff --git a/demo/css/hamburgers.min.css b/demo/css/hamburgers.min.css new file mode 100644 index 0000000..26a404f --- /dev/null +++ b/demo/css/hamburgers.min.css @@ -0,0 +1,7 @@ +/*! + * Hamburgers + * @description Tasty CSS-animated hamburgers + * @author Jonathan Suh @jonsuh + * @site https://jonsuh.com/hamburgers + * @link https://github.com/jonsuh/hamburgers + */.hamburger{font:inherit;display:inline-block;overflow:visible;margin:0;padding:15px;cursor:pointer;transition-timing-function:linear;transition-duration:.15s;transition-property:opacity,filter;text-transform:none;color:inherit;border:0;background-color:transparent}.hamburger.is-active:hover,.hamburger:hover{opacity:.7}.hamburger.is-active .hamburger-inner,.hamburger.is-active .hamburger-inner:after,.hamburger.is-active .hamburger-inner:before{background-color:#000}.hamburger-box{position:relative;display:inline-block;width:40px;height:24px}.hamburger-inner{top:50%;display:block;margin-top:-2px}.hamburger-inner,.hamburger-inner:after,.hamburger-inner:before{position:absolute;width:40px;height:4px;transition-timing-function:ease;transition-duration:.15s;transition-property:transform;border-radius:4px;background-color:#000}.hamburger-inner:after,.hamburger-inner:before{display:block;content:""}.hamburger-inner:before{top:-10px}.hamburger-inner:after{bottom:-10px}.hamburger--3dx .hamburger-box{perspective:80px}.hamburger--3dx .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx .hamburger-inner:after,.hamburger--3dx .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx.is-active .hamburger-inner{transform:rotateY(180deg);background-color:transparent!important}.hamburger--3dx.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dx.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dx-r .hamburger-box{perspective:80px}.hamburger--3dx-r .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx-r .hamburger-inner:after,.hamburger--3dx-r .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dx-r.is-active .hamburger-inner{transform:rotateY(-180deg);background-color:transparent!important}.hamburger--3dx-r.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dx-r.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dy .hamburger-box{perspective:80px}.hamburger--3dy .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy .hamburger-inner:after,.hamburger--3dy .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy.is-active .hamburger-inner{transform:rotateX(-180deg);background-color:transparent!important}.hamburger--3dy.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dy.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dy-r .hamburger-box{perspective:80px}.hamburger--3dy-r .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy-r .hamburger-inner:after,.hamburger--3dy-r .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dy-r.is-active .hamburger-inner{transform:rotateX(180deg);background-color:transparent!important}.hamburger--3dy-r.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dy-r.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dxy .hamburger-box{perspective:80px}.hamburger--3dxy .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy .hamburger-inner:after,.hamburger--3dxy .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy.is-active .hamburger-inner{transform:rotateX(180deg) rotateY(180deg);background-color:transparent!important}.hamburger--3dxy.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dxy.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--3dxy-r .hamburger-box{perspective:80px}.hamburger--3dxy-r .hamburger-inner{transition:transform .15s cubic-bezier(.645,.045,.355,1),background-color 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy-r .hamburger-inner:after,.hamburger--3dxy-r .hamburger-inner:before{transition:transform 0s cubic-bezier(.645,.045,.355,1) .1s}.hamburger--3dxy-r.is-active .hamburger-inner{transform:rotateX(180deg) rotateY(180deg) rotate(-180deg);background-color:transparent!important}.hamburger--3dxy-r.is-active .hamburger-inner:before{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--3dxy-r.is-active .hamburger-inner:after{transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--arrow.is-active .hamburger-inner:before{transform:translate3d(-8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrow.is-active .hamburger-inner:after{transform:translate3d(-8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--arrow-r.is-active .hamburger-inner:before{transform:translate3d(8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--arrow-r.is-active .hamburger-inner:after{transform:translate3d(8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowalt .hamburger-inner:before{transition:top .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt .hamburger-inner:after{transition:bottom .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt.is-active .hamburger-inner:before{top:0;transition:top .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s;transform:translate3d(-8px,-10px,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowalt.is-active .hamburger-inner:after{bottom:0;transition:bottom .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s;transform:translate3d(-8px,10px,0) rotate(45deg) scaleX(.7)}.hamburger--arrowalt-r .hamburger-inner:before{transition:top .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt-r .hamburger-inner:after{transition:bottom .1s ease .1s,transform .1s cubic-bezier(.165,.84,.44,1)}.hamburger--arrowalt-r.is-active .hamburger-inner:before{top:0;transition:top .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s;transform:translate3d(8px,-10px,0) rotate(45deg) scaleX(.7)}.hamburger--arrowalt-r.is-active .hamburger-inner:after{bottom:0;transition:bottom .1s ease,transform .1s cubic-bezier(.895,.03,.685,.22) .1s;transform:translate3d(8px,10px,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowturn.is-active .hamburger-inner{transform:rotate(-180deg)}.hamburger--arrowturn.is-active .hamburger-inner:before{transform:translate3d(8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--arrowturn.is-active .hamburger-inner:after{transform:translate3d(8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowturn-r.is-active .hamburger-inner{transform:rotate(-180deg)}.hamburger--arrowturn-r.is-active .hamburger-inner:before{transform:translate3d(-8px,0,0) rotate(-45deg) scaleX(.7)}.hamburger--arrowturn-r.is-active .hamburger-inner:after{transform:translate3d(-8px,0,0) rotate(45deg) scaleX(.7)}.hamburger--boring .hamburger-inner,.hamburger--boring .hamburger-inner:after,.hamburger--boring .hamburger-inner:before{transition-property:none}.hamburger--boring.is-active .hamburger-inner{transform:rotate(45deg)}.hamburger--boring.is-active .hamburger-inner:before{top:0;opacity:0}.hamburger--boring.is-active .hamburger-inner:after{bottom:0;transform:rotate(-90deg)}.hamburger--collapse .hamburger-inner{top:auto;bottom:0;transition-delay:.13s;transition-timing-function:cubic-bezier(.55,.055,.675,.19);transition-duration:.13s}.hamburger--collapse .hamburger-inner:after{top:-20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,opacity .1s linear}.hamburger--collapse .hamburger-inner:before{transition:top .12s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--collapse.is-active .hamburger-inner{transition-delay:.22s;transition-timing-function:cubic-bezier(.215,.61,.355,1);transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--collapse.is-active .hamburger-inner:after{top:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),opacity .1s linear .22s;opacity:0}.hamburger--collapse.is-active .hamburger-inner:before{top:0;transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .16s,transform .13s cubic-bezier(.215,.61,.355,1) .25s;transform:rotate(-90deg)}.hamburger--collapse-r .hamburger-inner{top:auto;bottom:0;transition-delay:.13s;transition-timing-function:cubic-bezier(.55,.055,.675,.19);transition-duration:.13s}.hamburger--collapse-r .hamburger-inner:after{top:-20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,opacity .1s linear}.hamburger--collapse-r .hamburger-inner:before{transition:top .12s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--collapse-r.is-active .hamburger-inner{transition-delay:.22s;transition-timing-function:cubic-bezier(.215,.61,.355,1);transform:translate3d(0,-10px,0) rotate(45deg)}.hamburger--collapse-r.is-active .hamburger-inner:after{top:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),opacity .1s linear .22s;opacity:0}.hamburger--collapse-r.is-active .hamburger-inner:before{top:0;transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .16s,transform .13s cubic-bezier(.215,.61,.355,1) .25s;transform:rotate(90deg)}.hamburger--elastic .hamburger-inner{top:2px;transition-timing-function:cubic-bezier(.68,-.55,.265,1.55);transition-duration:.275s}.hamburger--elastic .hamburger-inner:before{top:10px;transition:opacity .125s ease .275s}.hamburger--elastic .hamburger-inner:after{top:20px;transition:transform .275s cubic-bezier(.68,-.55,.265,1.55)}.hamburger--elastic.is-active .hamburger-inner{transition-delay:75ms;transform:translate3d(0,10px,0) rotate(135deg)}.hamburger--elastic.is-active .hamburger-inner:before{transition-delay:0s;opacity:0}.hamburger--elastic.is-active .hamburger-inner:after{transition-delay:75ms;transform:translate3d(0,-20px,0) rotate(-270deg)}.hamburger--elastic-r .hamburger-inner{top:2px;transition-timing-function:cubic-bezier(.68,-.55,.265,1.55);transition-duration:.275s}.hamburger--elastic-r .hamburger-inner:before{top:10px;transition:opacity .125s ease .275s}.hamburger--elastic-r .hamburger-inner:after{top:20px;transition:transform .275s cubic-bezier(.68,-.55,.265,1.55)}.hamburger--elastic-r.is-active .hamburger-inner{transition-delay:75ms;transform:translate3d(0,10px,0) rotate(-135deg)}.hamburger--elastic-r.is-active .hamburger-inner:before{transition-delay:0s;opacity:0}.hamburger--elastic-r.is-active .hamburger-inner:after{transition-delay:75ms;transform:translate3d(0,-20px,0) rotate(270deg)}.hamburger--emphatic{overflow:hidden}.hamburger--emphatic .hamburger-inner{transition:background-color .125s ease-in .175s}.hamburger--emphatic .hamburger-inner:before{left:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,left .125s ease-in .175s}.hamburger--emphatic .hamburger-inner:after{top:10px;right:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,right .125s ease-in .175s}.hamburger--emphatic.is-active .hamburger-inner{transition-delay:0s;transition-timing-function:ease-out;background-color:transparent!important}.hamburger--emphatic.is-active .hamburger-inner:before{top:-80px;left:-80px;transition:left .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s;transform:translate3d(80px,80px,0) rotate(45deg)}.hamburger--emphatic.is-active .hamburger-inner:after{top:-80px;right:-80px;transition:right .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s;transform:translate3d(-80px,80px,0) rotate(-45deg)}.hamburger--emphatic-r{overflow:hidden}.hamburger--emphatic-r .hamburger-inner{transition:background-color .125s ease-in .175s}.hamburger--emphatic-r .hamburger-inner:before{left:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,left .125s ease-in .175s}.hamburger--emphatic-r .hamburger-inner:after{top:10px;right:0;transition:transform .125s cubic-bezier(.6,.04,.98,.335),top .05s linear .125s,right .125s ease-in .175s}.hamburger--emphatic-r.is-active .hamburger-inner{transition-delay:0s;transition-timing-function:ease-out;background-color:transparent!important}.hamburger--emphatic-r.is-active .hamburger-inner:before{top:80px;left:-80px;transition:left .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s;transform:translate3d(80px,-80px,0) rotate(-45deg)}.hamburger--emphatic-r.is-active .hamburger-inner:after{top:80px;right:-80px;transition:right .125s ease-out,top .05s linear .125s,transform .125s cubic-bezier(.075,.82,.165,1) .175s;transform:translate3d(-80px,-80px,0) rotate(45deg)}.hamburger--minus .hamburger-inner:after,.hamburger--minus .hamburger-inner:before{transition:bottom .08s ease-out 0s,top .08s ease-out 0s,opacity 0s linear}.hamburger--minus.is-active .hamburger-inner:after,.hamburger--minus.is-active .hamburger-inner:before{transition:bottom .08s ease-out,top .08s ease-out,opacity 0s linear .08s;opacity:0}.hamburger--minus.is-active .hamburger-inner:before{top:0}.hamburger--minus.is-active .hamburger-inner:after{bottom:0}.hamburger--slider .hamburger-inner{top:2px}.hamburger--slider .hamburger-inner:before{top:10px;transition-timing-function:ease;transition-duration:.15s;transition-property:transform,opacity}.hamburger--slider .hamburger-inner:after{top:20px}.hamburger--slider.is-active .hamburger-inner{transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--slider.is-active .hamburger-inner:before{transform:rotate(-45deg) translate3d(-5.71429px,-6px,0);opacity:0}.hamburger--slider.is-active .hamburger-inner:after{transform:translate3d(0,-20px,0) rotate(-90deg)}.hamburger--slider-r .hamburger-inner{top:2px}.hamburger--slider-r .hamburger-inner:before{top:10px;transition-timing-function:ease;transition-duration:.15s;transition-property:transform,opacity}.hamburger--slider-r .hamburger-inner:after{top:20px}.hamburger--slider-r.is-active .hamburger-inner{transform:translate3d(0,10px,0) rotate(-45deg)}.hamburger--slider-r.is-active .hamburger-inner:before{transform:rotate(45deg) translate3d(5.71429px,-6px,0);opacity:0}.hamburger--slider-r.is-active .hamburger-inner:after{transform:translate3d(0,-20px,0) rotate(90deg)}.hamburger--spin .hamburger-inner{transition-timing-function:cubic-bezier(.55,.055,.675,.19);transition-duration:.22s}.hamburger--spin .hamburger-inner:before{transition:top .1s ease-in .25s,opacity .1s ease-in}.hamburger--spin .hamburger-inner:after{transition:bottom .1s ease-in .25s,transform .22s cubic-bezier(.55,.055,.675,.19)}.hamburger--spin.is-active .hamburger-inner{transition-delay:.12s;transition-timing-function:cubic-bezier(.215,.61,.355,1);transform:rotate(225deg)}.hamburger--spin.is-active .hamburger-inner:before{top:0;transition:top .1s ease-out,opacity .1s ease-out .12s;opacity:0}.hamburger--spin.is-active .hamburger-inner:after{bottom:0;transition:bottom .1s ease-out,transform .22s cubic-bezier(.215,.61,.355,1) .12s;transform:rotate(-90deg)}.hamburger--spin-r .hamburger-inner{transition-timing-function:cubic-bezier(.55,.055,.675,.19);transition-duration:.22s}.hamburger--spin-r .hamburger-inner:before{transition:top .1s ease-in .25s,opacity .1s ease-in}.hamburger--spin-r .hamburger-inner:after{transition:bottom .1s ease-in .25s,transform .22s cubic-bezier(.55,.055,.675,.19)}.hamburger--spin-r.is-active .hamburger-inner{transition-delay:.12s;transition-timing-function:cubic-bezier(.215,.61,.355,1);transform:rotate(-225deg)}.hamburger--spin-r.is-active .hamburger-inner:before{top:0;transition:top .1s ease-out,opacity .1s ease-out .12s;opacity:0}.hamburger--spin-r.is-active .hamburger-inner:after{bottom:0;transition:bottom .1s ease-out,transform .22s cubic-bezier(.215,.61,.355,1) .12s;transform:rotate(90deg)}.hamburger--spring .hamburger-inner{top:2px;transition:background-color 0s linear .13s}.hamburger--spring .hamburger-inner:before{top:10px;transition:top .1s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--spring .hamburger-inner:after{top:20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--spring.is-active .hamburger-inner{transition-delay:.22s;background-color:transparent!important}.hamburger--spring.is-active .hamburger-inner:before{top:0;transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .15s,transform .13s cubic-bezier(.215,.61,.355,1) .22s;transform:translate3d(0,10px,0) rotate(45deg)}.hamburger--spring.is-active .hamburger-inner:after{top:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),transform .13s cubic-bezier(.215,.61,.355,1) .22s;transform:translate3d(0,10px,0) rotate(-45deg)}.hamburger--spring-r .hamburger-inner{top:auto;bottom:0;transition-delay:0s;transition-timing-function:cubic-bezier(.55,.055,.675,.19);transition-duration:.13s}.hamburger--spring-r .hamburger-inner:after{top:-20px;transition:top .2s cubic-bezier(.33333,.66667,.66667,1) .2s,opacity 0s linear}.hamburger--spring-r .hamburger-inner:before{transition:top .1s cubic-bezier(.33333,.66667,.66667,1) .2s,transform .13s cubic-bezier(.55,.055,.675,.19)}.hamburger--spring-r.is-active .hamburger-inner{transition-delay:.22s;transition-timing-function:cubic-bezier(.215,.61,.355,1);transform:translate3d(0,-10px,0) rotate(-45deg)}.hamburger--spring-r.is-active .hamburger-inner:after{top:0;transition:top .2s cubic-bezier(.33333,0,.66667,.33333),opacity 0s linear .22s;opacity:0}.hamburger--spring-r.is-active .hamburger-inner:before{top:0;transition:top .1s cubic-bezier(.33333,0,.66667,.33333) .15s,transform .13s cubic-bezier(.215,.61,.355,1) .22s;transform:rotate(90deg)}.hamburger--stand .hamburger-inner{transition:transform 75ms cubic-bezier(.55,.055,.675,.19) .15s,background-color 0s linear 75ms}.hamburger--stand .hamburger-inner:before{transition:top 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand .hamburger-inner:after{transition:bottom 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand.is-active .hamburger-inner{transition:transform 75ms cubic-bezier(.215,.61,.355,1) 0s,background-color 0s linear .15s;transform:rotate(90deg);background-color:transparent!important}.hamburger--stand.is-active .hamburger-inner:before{top:0;transition:top 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s;transform:rotate(-45deg)}.hamburger--stand.is-active .hamburger-inner:after{bottom:0;transition:bottom 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s;transform:rotate(45deg)}.hamburger--stand-r .hamburger-inner{transition:transform 75ms cubic-bezier(.55,.055,.675,.19) .15s,background-color 0s linear 75ms}.hamburger--stand-r .hamburger-inner:before{transition:top 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand-r .hamburger-inner:after{transition:bottom 75ms ease-in 75ms,transform 75ms cubic-bezier(.55,.055,.675,.19) 0s}.hamburger--stand-r.is-active .hamburger-inner{transition:transform 75ms cubic-bezier(.215,.61,.355,1) 0s,background-color 0s linear .15s;transform:rotate(-90deg);background-color:transparent!important}.hamburger--stand-r.is-active .hamburger-inner:before{top:0;transition:top 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s;transform:rotate(-45deg)}.hamburger--stand-r.is-active .hamburger-inner:after{bottom:0;transition:bottom 75ms ease-out .1s,transform 75ms cubic-bezier(.215,.61,.355,1) .15s;transform:rotate(45deg)}.hamburger--squeeze .hamburger-inner{transition-timing-function:cubic-bezier(.55,.055,.675,.19);transition-duration:75ms}.hamburger--squeeze .hamburger-inner:before{transition:top 75ms ease .12s,opacity 75ms ease}.hamburger--squeeze .hamburger-inner:after{transition:bottom 75ms ease .12s,transform 75ms cubic-bezier(.55,.055,.675,.19)}.hamburger--squeeze.is-active .hamburger-inner{transition-delay:.12s;transition-timing-function:cubic-bezier(.215,.61,.355,1);transform:rotate(45deg)}.hamburger--squeeze.is-active .hamburger-inner:before{top:0;transition:top 75ms ease,opacity 75ms ease .12s;opacity:0}.hamburger--squeeze.is-active .hamburger-inner:after{bottom:0;transition:bottom 75ms ease,transform 75ms cubic-bezier(.215,.61,.355,1) .12s;transform:rotate(-90deg)}.hamburger--vortex .hamburger-inner{transition-timing-function:cubic-bezier(.19,1,.22,1);transition-duration:.2s}.hamburger--vortex .hamburger-inner:after,.hamburger--vortex .hamburger-inner:before{transition-delay:.1s;transition-timing-function:linear;transition-duration:0s}.hamburger--vortex .hamburger-inner:before{transition-property:top,opacity}.hamburger--vortex .hamburger-inner:after{transition-property:bottom,transform}.hamburger--vortex.is-active .hamburger-inner{transition-timing-function:cubic-bezier(.19,1,.22,1);transform:rotate(765deg)}.hamburger--vortex.is-active .hamburger-inner:after,.hamburger--vortex.is-active .hamburger-inner:before{transition-delay:0s}.hamburger--vortex.is-active .hamburger-inner:before{top:0;opacity:0}.hamburger--vortex.is-active .hamburger-inner:after{bottom:0;transform:rotate(90deg)}.hamburger--vortex-r .hamburger-inner{transition-timing-function:cubic-bezier(.19,1,.22,1);transition-duration:.2s}.hamburger--vortex-r .hamburger-inner:after,.hamburger--vortex-r .hamburger-inner:before{transition-delay:.1s;transition-timing-function:linear;transition-duration:0s}.hamburger--vortex-r .hamburger-inner:before{transition-property:top,opacity}.hamburger--vortex-r .hamburger-inner:after{transition-property:bottom,transform}.hamburger--vortex-r.is-active .hamburger-inner{transition-timing-function:cubic-bezier(.19,1,.22,1);transform:rotate(-765deg)}.hamburger--vortex-r.is-active .hamburger-inner:after,.hamburger--vortex-r.is-active .hamburger-inner:before{transition-delay:0s}.hamburger--vortex-r.is-active .hamburger-inner:before{top:0;opacity:0}.hamburger--vortex-r.is-active .hamburger-inner:after{bottom:0;transform:rotate(-90deg)} diff --git a/demo/css/main.css b/demo/css/main.css new file mode 100644 index 0000000..a85a8af --- /dev/null +++ b/demo/css/main.css @@ -0,0 +1,7 @@ +@import './reset.css' layer(reset); +@import './custom_properties.css' layer(custom-properties); +@import './tags.css' layer(tags); +@import './grid.css' layer(grid); +@import './utility_classes.css' layer(classes); + +@import './fonts.css'; diff --git a/demo/css/reset.css b/demo/css/reset.css new file mode 100644 index 0000000..c3b67ee --- /dev/null +++ b/demo/css/reset.css @@ -0,0 +1,114 @@ +/*** + The new CSS reset - version 1.11.3 (last updated 25.08.2024) + GitHub page: https://github.com/elad2412/the-new-css-reset +***/ + +/* + Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property + - The "symbol *" part is to solve Firefox SVG sprite bug + - The "html" element is excluded, otherwise a bug in Chrome breaks the CSS hyphens property (https://github.com/elad2412/the-new-css-reset/issues/36) + */ +*:where(:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)) { + all: unset; + display: revert; +} + +/* Preferred box-sizing value */ +*, +*::before, +*::after { + box-sizing: border-box; +} + +/* Fix mobile Safari increase font-size on landscape mode */ +html { + -moz-text-size-adjust: none; + -webkit-text-size-adjust: none; + text-size-adjust: none; +} + +/* Reapply the pointer cursor for anchor tags */ +a, button { + cursor: revert; +} + +/* Remove list styles (bullets/numbers) */ +ol, ul, menu, summary { + list-style: none; +} + +/* Firefox: solve issue where nested ordered lists continue numbering from parent (https://bugzilla.mozilla.org/show_bug.cgi?id=1881517) */ +ol { + counter-reset: revert; +} + +/* For images to not be able to exceed their container */ +img { + max-inline-size: 100%; + max-block-size: 100%; +} + +/* removes spacing between cells in tables */ +table { + border-collapse: collapse; +} + +/* Safari - solving issue when using user-select:none on the text input doesn't working */ +input, textarea { + -webkit-user-select: auto; +} + +/* revert the 'white-space' property for textarea elements on Safari */ +textarea { + white-space: revert; +} + +/* minimum style to allow to style meter element */ +meter { + -webkit-appearance: revert; + appearance: revert; +} + +/* preformatted text - use only for this feature */ +:where(pre) { + all: revert; + box-sizing: border-box; +} + +/* reset default text opacity of input placeholder */ +::placeholder { + color: unset; +} + +/* fix the feature of 'hidden' attribute. + display:revert; revert to element instead of attribute */ +:where([hidden]) { + display: none; +} + +/* revert for bug in Chromium browsers + - fix for the content editable attribute will work properly. + - webkit-user-select: auto; added for Safari in case of using user-select:none on wrapper element*/ +:where([contenteditable]:not([contenteditable="false"])) { + -moz-user-modify: read-write; + -webkit-user-modify: read-write; + overflow-wrap: break-word; + -webkit-line-break: after-white-space; + -webkit-user-select: auto; +} + +/* apply back the draggable feature - exist only in Chromium and Safari */ +:where([draggable="true"]) { + -webkit-user-drag: element; +} + +/* Revert Modal native behavior */ +:where(dialog:modal) { + all: revert; + box-sizing: border-box; +} + +/* Remove details summary webkit styles */ +::-webkit-details-marker { + display: none; +} diff --git a/demo/css/tags.css b/demo/css/tags.css new file mode 100644 index 0000000..7dfd274 --- /dev/null +++ b/demo/css/tags.css @@ -0,0 +1,166 @@ +/* debug */ +/* *, *::before, *::after { + outline: 2px solid lime; +} */ + +:root { + interpolate-size: allow-keywords; + scrollbar-color: color-mix(in oklab, var(--color-02) 40%, transparent) + color-mix(in oklab, var(--color-01) 40%, transparent); + scrollbar-gutter: stable; +} + +body { + background-color: var(--color-01); + color: var(--color-02); + font: normal normal 300 clamp(1.6rem, 1.4dvw, 2.0rem)/1.25 'Helvetica', sans-serif; + letter-spacing: .25px; + overflow-x: clip; +} + +button { + background: var(--color-01); + border: 1px solid var(--color-02); + color: var(--color-02); + padding: var(--quarter-space); + &:not(:last-child) { margin-bottom: var(--half-space); } + &:hover { cursor: pointer; } +} + +em { + font-style: italic; + font-weight: bolder; +} + +figcaption { + font-size: smaller; +} + +h1, h2, h3, h4, h5, h6 { text-wrap: balance; } + +html { + font-size: 62.5%; + scroll-behavior: smooth; +} + +img { display: block; } + +small { font-size: .35lh; } + +strong { font-weight: 600; } + +svg { display: block; } + +figcaption, li, ol, p { + text-wrap: balance; + text-wrap: pretty; +} + + + +/* ####### ##### ###### ## ## ###### */ +/* ## ## ## ## ## ### ### ## */ +/* ###### ## ## ###### ## # ## ##### */ +/* ## ## ## ## ## ## ## ## */ +/* ## ##### ## ## ## ## ###### */ + +form { + container: form / inline-size; + + ::placeholder { opacity: .65; } + + fieldset { + form > & { + column-gap: clamp(var(--three-quarter-space), 3dvw, var(--space)); + display: grid; + grid-template-columns: repeat(2, 1fr); + row-gap: var(--one-and-three-quarter-space); + + @container form (width < 400px) { + grid-template-columns: 1fr; + } + } + + margin-top: -.5lh; + padding-top: .75lh; + + legend { + font-weight: bolder; + position: relative; + top: .5lh; + } + } + + .form-group { + position: relative; + transition: background .25s linear; + + input, select, textarea { + border: 1px solid var(--color-01); + width: 100%; + + &:not(:last-child, input[type="checkbox"], input[type="radio"]) { + margin-bottom: var(--half-space); + } + } + + input[type="checkbox"], + input[type="radio"] { + aspect-ratio: 1; + background: var(--color-02); + height: .75lh; + width: .75lh; + + &:checked { background: var(--color-01); } + + .form-group:has(&) { + align-content: start; + display: flex; + flex-wrap: wrap; + gap: .5lh 2ch; + + & > :where(label, legend) { flex: 1 1 100%; } + } + } + + label { + &:not(:where(input[type="checkbox"], input[type="radio"]) + &, + &:has(+ :where([type="checkbox"], [type="radio"])) + ) { font-weight: bolder; } + + &:hover { cursor: pointer; } + } + + textarea { height: 3lh; } + + :disabled, label:has(:disabled, ~ :disabled), :disabled ~ label { + border-color: color-mix(in oklab, var(--color-01) 40%, transparent); + color: color-mix(in oklab, var(--color-01) 40%, transparent); + &:hover { cursor: not-allowed; } + } + + /* wrapper for checkbox/radio input and label elements */ + .form-group__item { + align-items: center; + display: inline-flex; + flex-direction: row; + flex-wrap: nowrap; + gap: .5ch; + + & *:hover { cursor: pointer; } + } + + .required__indicator { color: var(--danger-color); } + + &.invalid { + background: color-mix(in oklab, var(--danger-color) 5%, transparent); + + .invalid__message { + color: var(--danger-color); + font-size: 1.0rem; + inset: calc(100% + .5lh) auto auto 0; + position: absolute; + } + } + } +} diff --git a/demo/css/utility_classes.css b/demo/css/utility_classes.css new file mode 100644 index 0000000..94d3e4d --- /dev/null +++ b/demo/css/utility_classes.css @@ -0,0 +1,56 @@ +.align-center { + margin-left: auto; + margin-right: auto; + text-align: center; +} + +.align-left { + margin-left: 0; + margin-right: auto; + text-align: left; +} + +.align-right { + margin-left: auto; + margin-right: 0; + text-align: right; +} + +.keep { white-space: nowrap; } + +/* https://fajarwz.com/blog/how-to-solve-unwanted-css-transitions-on-page-load/ */ +.no-transition, +.no-transition * { + -webkit-transition: none !important; + -moz-transition: none !important; + -ms-transition: none !important; + -o-transition: none !important; + transition: none !important; +} + + + + +@keyframes parallax-background { + to { background-position-y: -200px; } +} + +.parallax-background { + position: relative; + overflow: clip; + background: none; + + &::before { + animation: parallax-background linear; + animation-timeline: view(); + background-image: var(--parallax-background); /* define --parallax-background in element's style attribute */ + background-position-x: center; + background-repeat: no-repeat; + background-size: cover; + content: ''; + height: calc(100% + 200px); + inset: 0; + position: absolute; + z-index: -1; + } +} diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..4c2acdd --- /dev/null +++ b/demo/index.html @@ -0,0 +1,144 @@ + + + + + + + Form Validation + + + + + +
+
+
+ +
+ Form Validation + +
+ +
+
+ +
+ + +
+ +
+ + +
Input element with type="text" attribute.
+
+ +
+ (Numbers only.) + +
This field uses a user supplied regular expression to test against.
+
+ +
+ + +
+ +
+ + +
Input element with type="email" attribute.
+
+ +
+ + +
Input element with type="password" attribute. The 'Password Confirm' field is auto-generated.
+
+ +
+ + +
Exclude fields.
+
+ +
+ +
+
+
This field is a div element, not an input element.
+
+ +
+ + + +
Fields can be dynamically disabled/enabled.
+
+ +
+ + +
+ +
+ + +
+ +
+
+ Check Group + + + + + + + + + + + + +
+
+ +
+
+ Radio Group + + + + + + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + +
+
+
+ + diff --git a/demo/js/main.js b/demo/js/main.js new file mode 100644 index 0000000..71b84ab --- /dev/null +++ b/demo/js/main.js @@ -0,0 +1,2 @@ +import('./validation/validation.js') +const save = () => alert('Congrats! You successfully filled out the form. Amazing.') diff --git a/demo/js/validation/README.md b/demo/js/validation/README.md new file mode 100644 index 0000000..165ee51 --- /dev/null +++ b/demo/js/validation/README.md @@ -0,0 +1,463 @@ +# Form Validation + +Importing the `Validation` class queries the current page for `
` elements +and disables the default browser [constraint validation](https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation) +by adding a `novalidate` attribute to that element. + +The default behavior is to validate each field when their value is updated, +and validate the entire form when it is submitted. This can be changed to only +validate on form submission by setting [`onlyOnSubmit`](#onlyonsubmit) to `true` on the +instance. + +Once a field is marked invalid, it will always re-validate when its value is +changed regardless of the [`onlyOnSubmit`](#onlyOnSubmit) value. + +> `required` fields are tested for blank first. If this check is passed, the +field will then test for [custom rules](#custom-validation) if present. If +there are no custom rules, some fields are also tested further based on their +`type` attribute value. These are described [below](#markup). + +## Required Fields + +Usually, the majority of fields in a form need validation. To make setup +easier, instances of the *Validation* class have a default [`reqAll`](#reqall) +value of `true`. This marks all fields that meet the following criteria +required and needing validation: + +* Have a `name` attribute. +* Not [`disabled`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled). + +Indivudual fields can then be excluded from validation as described [below](#reqall). + +This functionality can be inverted by setting [`reqAll`](#reqall) to `false`, +and manually giving your required fields a [`required`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required) +attribute. + +```html +
+ + +
+``` + +`` `type` attribute values of `checkbox` and `radio` only need one option to have the +`required` attribute, however, it is recommended to add it to all options for +consistency. More information on checkbox and radio fields can be found [below](#checkbox-and-radio-fields). + +### Required Indicator + +A `` tag with class of `required__indicator` containing an asterisk(*) +character will be inserted [`beforeend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML#beforeend) +of a required field's `