diff --git a/src/components/atoms/blockquote/blockquote.config.yml b/src/components/atoms/blockquote/blockquote.config.yml new file mode 100644 index 0000000..82794a1 --- /dev/null +++ b/src/components/atoms/blockquote/blockquote.config.yml @@ -0,0 +1,11 @@ +title: "Blockquote" +status: "ready" +context: + quote: "So how do we go about creating a digital product that works both for an organisation and for its users?" + +variants: + - name: Attributed + context: + name: "Leigh Dodds" + quote: "“I thoroughly enjoyed working with the team from Kind on the open standards for data guidebook. They quickly understood both our needs and the broader goals of the project.”" + role: "Director of Advisory at The ODI" diff --git a/src/components/atoms/blockquote/blockquote.twig b/src/components/atoms/blockquote/blockquote.twig new file mode 100644 index 0000000..ee7f920 --- /dev/null +++ b/src/components/atoms/blockquote/blockquote.twig @@ -0,0 +1,31 @@ +{# + # Blockquote Molecule + # + # @param name {string} Optional name of the quote author. + # @param quote {string} Required quote content. + # @param role {string} Optional authors job title. + #} + +{# Params #} +{% set name = name | default(null) %} +{% set quote = quote | default() %} +{% set role = role | default(null) %} + +{# Internal vars #} +{% set el = (name | default(false)) ? 'figure' : 'div' %} + +{# Output #} +<{{el}} class="my-double"> + + {% if name %} +
+ {{ name }}{% if role %}, {{ role }}{% endif %} +
+ {% endif %} + +
+

+ “{{ quote }}” +

+
+ diff --git a/src/components/atoms/checkbox/_checkbox.postcss b/src/components/atoms/checkbox/_checkbox.postcss new file mode 100644 index 0000000..ba95f6b --- /dev/null +++ b/src/components/atoms/checkbox/_checkbox.postcss @@ -0,0 +1,65 @@ +/* ========================================================================== + CHECKBOXES + ========================================================================== */ + +.checkbox { + + @apply flex flex-wrap items-center -ml-4; + + /* Hide the real checkbox */ + & input { + @apply absolute opacity-0; + } + + /* Create a faux checkbox */ + & .checkbox__label { + @apply + inline-flex + items-center + p-4 + ; + + &::before { + @apply + border + bg-white + flex + items-center + justify-center + mr-4 + h-12 w-12 + ; + + content: ''; + } + } + + /* Make disabled controls look like they are disabled. */ + & input:disabled + .checkbox__label::before { + @apply bg-grey-light; + } + + /* Update the faux checkbox styles on checked or focussed states */ + & input:checked + .checkbox__label::before, + & input:focus + .checkbox__label::before { + @apply bg-blue border-black; + } + + & input:checked + .checkbox__label::before { + content: '✓'; + } + + /* Apply disabled checkbox styles to the checkbox label */ + & input:disabled + .checkbox__label { + @apply cursor-not-allowed text-grey; + } + + /* Update faux checkbox styles on user action */ + & input:not(:disabled) + .checkbox__label:hover, + & input:not(:disabled) + .checkbox__label:focus, + & input:not(:disabled) + .checkbox__label:focus:active { + &::before { + @apply border-blue; + } + } +} diff --git a/src/components/atoms/checkbox/checkbox.config.yml b/src/components/atoms/checkbox/checkbox.config.yml new file mode 100644 index 0000000..fa00b92 --- /dev/null +++ b/src/components/atoms/checkbox/checkbox.config.yml @@ -0,0 +1,23 @@ +title: "Checkbox" +status: prototype +context: + label: Checkbox + +variants: + - + name: checked + context: + checked: true + fieldname: checkbox-checked + label: Checked checkbox + - + name: disabled + context: + label: Disabled checkbox + disabled: true + - + name: disabled-checked + context: + label: Checked and disabled checkbox + disabled: true + checked: true diff --git a/src/components/atoms/checkbox/checkbox.twig b/src/components/atoms/checkbox/checkbox.twig new file mode 100644 index 0000000..db55295 --- /dev/null +++ b/src/components/atoms/checkbox/checkbox.twig @@ -0,0 +1,10 @@ + + diff --git a/src/components/atoms/fonts/_fonts.postcss b/src/components/atoms/fonts/_fonts.postcss new file mode 100644 index 0000000..2b48902 --- /dev/null +++ b/src/components/atoms/fonts/_fonts.postcss @@ -0,0 +1,35 @@ +/* ========================================================================== + WEBFONTS + ========================================================================== */ + +/* +@font-face { + font-display: swap; + font-family: "Inter"; + font-style: italic; + font-weight: 400; + src: + url("../fonts/Inter-Italic.woff2?v=3.11") format("woff2"), + url("../fonts/Inter-Italic.woff?v=3.11") format("woff"); +} + +@font-face { + font-display: swap; + font-family: "Inter"; + font-style: normal; + font-weight: 400; + src: + url("../fonts/Inter-Regular.woff2?v=3.11") format("woff2"), + url("../fonts/Inter-Regular.woff?v=3.11") format("woff"); +} + +@font-face { + font-display: swap; + font-family: "Inter"; + font-style: normal; + font-weight: 700; + src: + url("../fonts/Inter-Bold.woff2?v=3.11") format("woff2"), + url("../fonts/Inter-Bold.woff?v=3.11") format("woff"); +} +*/ diff --git a/src/components/atoms/fonts/fonts.config.yml b/src/components/atoms/fonts/fonts.config.yml new file mode 100644 index 0000000..86a31f7 --- /dev/null +++ b/src/components/atoms/fonts/fonts.config.yml @@ -0,0 +1,12 @@ +title: Fonts +status: wip + +context: + text: '

Body copy is set in [some font], a humanist sans-serif with great readability at typical sizes. + At purto convenire imperdiet mei, nobis omittantur duo ei. Eu platonem electram pri. Integre aliquando te qui, pro te liber referrentur, nostro malorum denique cu duo. Cu pri copiosae referrentur, vis in dico quidam melius. Utinam putant aeterno eam ad. Cu purto unum impetus eam, assum utinam aliquam ut his.

' + +variants: + - + name: Level 1 heading + context: + text: '

Headings use something bolder

' diff --git a/src/components/atoms/fonts/fonts.twig b/src/components/atoms/fonts/fonts.twig new file mode 100644 index 0000000..c39201b --- /dev/null +++ b/src/components/atoms/fonts/fonts.twig @@ -0,0 +1,15 @@ +{# + # Fonts atom + # + # @param {string} text - text + #} + +{%- set class = class | default('') -%} + +{% if class %} +
+ {{ text | raw }} +
+{% else %} + {{ text | raw }} +{% endif %} diff --git a/src/components/atoms/heading/README.md b/src/components/atoms/heading/README.md new file mode 100644 index 0000000..f2acef5 --- /dev/null +++ b/src/components/atoms/heading/README.md @@ -0,0 +1,7 @@ +## Heading - Data API +``` +@optional class - string - Additional classes +@optional el - string - The element you want this heading item to be rendered as, defaults to h2 +@optional href - string - The href for this heading item +@required text - string - The text for this heading item +``` diff --git a/src/components/atoms/heading/_heading.postcss b/src/components/atoms/heading/_heading.postcss new file mode 100644 index 0000000..43c67b1 --- /dev/null +++ b/src/components/atoms/heading/_heading.postcss @@ -0,0 +1,35 @@ +/* ========================================================================== + HEADINGS + ========================================================================== */ + +h1, +.h1, +h2, +.h2, +h3, +.h3, +h4, +.h4, +h5, +.h5, +h6, +.h6 { + + /* stylelint-disable-next-line no-descending-specificity */ + & > a { + @apply font-normal; + + color: inherit; + } +} + +h1, +.h1, +h2, +.h2, +h3, +.h3 { + /* Turn on kerning, common ligatures, contextual alternates, + titling caps and swashes for larger headings. Because sexy type. */ + font-feature-settings: "calt", "clig", "kern", "liga", "swsh", "titl"; +} diff --git a/src/components/atoms/heading/heading.config.yml b/src/components/atoms/heading/heading.config.yml new file mode 100644 index 0000000..e668109 --- /dev/null +++ b/src/components/atoms/heading/heading.config.yml @@ -0,0 +1,53 @@ +title: Headings +status: ready + +context: + el: h1 + text: heading ipsum dolor sit amet + +variants: + - + name: Level 2 heading + context: + el: h2 + - + name: Linked level 2 heading + context: + el: h2 + href: '#' + - + name: Level 3 heading + context: + el: h3 + - + name: Linked level 3 heading + context: + el: h3 + href: '#' + - + name: Level 4 heading + context: + el: h4 + - + name: Linked level 4 heading + context: + el: h4 + href: '#' + - + name: Level 5 heading + context: + el: h5 + - + name: Linked level 5 heading + context: + el: h5 + href: '#' + - + name: Level 6 heading + context: + el: h6 + - + name: Linked level 6 heading + context: + el: h6 + href: '#' diff --git a/src/components/atoms/heading/heading.twig b/src/components/atoms/heading/heading.twig new file mode 100644 index 0000000..284e6b4 --- /dev/null +++ b/src/components/atoms/heading/heading.twig @@ -0,0 +1,22 @@ +{# + # Heading atom + # + # @param text {string} - Required heading text. + #} + +{%- set el = el | default('h2') -%} +{%- set class = class | default('') -%} +{%- set text = text | default('') -%} +{%- set attrs = attrs | default({}) -%} +{%- set href = href | default() -%} +{%- if href -%} + {%- set attrs = attrs | merge({ href: href }) -%} +{%- endif -%} + +<{{ el }}{% if class %} class="{{ class }}"{% endif %}> +{% if href %} + {{ text }} +{% else %} + {{ text }} +{% endif %} + diff --git a/src/components/atoms/input/_input.postcss b/src/components/atoms/input/_input.postcss new file mode 100644 index 0000000..e862ffd --- /dev/null +++ b/src/components/atoms/input/_input.postcss @@ -0,0 +1,28 @@ +/* Set / reset some base form styles at the highest level */ +input { + color: currentColor; + font: inherit; + + &:disabled { + @apply + cursor-not-allowed; + } + + &::placeholder { + @apply text-text-grey; + + opacity: 0.75; + } +} + +/* Make texty-type inputs look like text inputs */ +.input { + @apply + p-2 + transition; + + &:focus { + /* Match Webkit's default styles in Firefox */ + outline: 2px solid rgb(0, 94, 205); + } +} diff --git a/src/components/atoms/input/input.config.yml b/src/components/atoms/input/input.config.yml new file mode 100644 index 0000000..7db620d --- /dev/null +++ b/src/components/atoms/input/input.config.yml @@ -0,0 +1,71 @@ +title: "Text type inputs" +status: ready +context: + type: text + +variants: + - + name: email address + context: + placeholder: Your email address… + type: email + - + name: telephone number + context: + type: tel + - + name: password + context: + type: password + - + name: number + context: + type: number + - + name: search + context: + type: search + - + name: date + context: + type: date + - + name: datetime + context: + type: datetime + - + name: datetime local + context: + type: datetime-local + - + name: month + context: + type: month + - + name: week + context: + type: week + - + name: time + context: + type: time + - + name: URL + context: + type: url + - + name: has-error + context: + state: error + - + name: has-success + context: + state: success + - + name: disabled + context: + disabled: true + - + name: readonly + context: + readonly: true diff --git a/src/components/atoms/input/input.twig b/src/components/atoms/input/input.twig new file mode 100644 index 0000000..13c5ed8 --- /dev/null +++ b/src/components/atoms/input/input.twig @@ -0,0 +1,38 @@ +{# + # Input atom + # + # @param {string} type + # @param {enum} state ['error','success'] + # @param {string|array} class + # @param {string} id + # @param {string} name + # @param {string} placeholder + # @param {string} value + # @param {string} placeholder + # @param {boolean} readonly + # @param {boolean} disabled + # @param {boolean} required + #} + +{# @todo inputs have no borders #} + +{% set state = state | default('') %} +{% set class = class | default([]) | merge (['input']) %} +{% if state == 'error' %} + {% set class = class | merge(['border-status-red']) %} +{% elseif state == 'success' %} + {% set class = class | merge(['border-status-green']) %} +{% endif %} + + diff --git a/src/components/atoms/label/label.config.yml b/src/components/atoms/label/label.config.yml new file mode 100644 index 0000000..5aee76f --- /dev/null +++ b/src/components/atoms/label/label.config.yml @@ -0,0 +1,14 @@ +status: ready +title: "Label" +context: + label: Label text + +variants: + - + name: has-error + context: + state: error + - + name: has-success + context: + state: success diff --git a/src/components/atoms/label/label.twig b/src/components/atoms/label/label.twig new file mode 100644 index 0000000..294a9e9 --- /dev/null +++ b/src/components/atoms/label/label.twig @@ -0,0 +1 @@ +{{ label }} diff --git a/src/components/atoms/link/README.md b/src/components/atoms/link/README.md new file mode 100644 index 0000000..f832e73 --- /dev/null +++ b/src/components/atoms/link/README.md @@ -0,0 +1,10 @@ +## Links - Data API +``` +@required href - string - The href for this meta item +@required text - string - The text for this meta item + +@optional arrow - bool - The optional arrow icon +@optional class - string - Additional classes +@optional external - bool - Mark links as external +@optional target - string - The target of the link +``` diff --git a/src/components/atoms/link/_link.postcss b/src/components/atoms/link/_link.postcss new file mode 100644 index 0000000..b74fff1 --- /dev/null +++ b/src/components/atoms/link/_link.postcss @@ -0,0 +1,8 @@ +/* ========================================================================== + LINKS + ========================================================================== */ + +/* Base element styles */ +a { + +} diff --git a/src/components/atoms/link/link.config.yml b/src/components/atoms/link/link.config.yml new file mode 100644 index 0000000..6549e08 --- /dev/null +++ b/src/components/atoms/link/link.config.yml @@ -0,0 +1,24 @@ +title: Links +status: ready +context: + href: "#" + text: Continue reading; + +variants: + - name: External link + context: + class: "" + href: "#" + external: true + text: Click here to go somewhere else… + - name: CTA link + context: + class: "a--cta hover:text-teal focus:text-teal font-display inline-flex items-center" + arrow: true + href: "#" + text: Go there now! + - name: Snazzy link + context: + class: "a--snazzy" + href: "#" + text: extremely long links should wrap as required and still be styled correctly on hove / active; diff --git a/src/components/atoms/link/link.twig b/src/components/atoms/link/link.twig new file mode 100644 index 0000000..ec97ff0 --- /dev/null +++ b/src/components/atoms/link/link.twig @@ -0,0 +1,31 @@ +{# + # Link atom + # + # @param arrow {boolean} - Optional include an arrow icon in the link. + # @param class {string} - Optional link classes'. + # @param external {boolean} - Optional mark the link as external and secure it. + # @param href {string} - Required. The Url for the link. + # @param target {string} - Optional. Link target attribute. + # @param text {string} - Required anchor text, ideally not ‘Click here’ or 'Read more'. + #} + +{# Params #} +{% set arrow = arrow | default(false) %} +{% set class = class | default('') %} +{% set external = external | default(false) %} +{% set href = href %} +{% set target = target | default(null) %} +{% set text = text %} + +{# Output #} + + {{- text -}} + {%- if arrow -%} + {% spaceless %} + {%- include '@icon' with { + blockClass: 'a--cta__arrow flex-none inline-block ml-4 text-currentColor w-4', + icon: 'arrow-cta', + } only -%} + {% endspaceless %} + {%- endif -%} + diff --git a/src/components/atoms/list/_list.config.yml b/src/components/atoms/list/_list.config.yml new file mode 100644 index 0000000..120f27e --- /dev/null +++ b/src/components/atoms/list/_list.config.yml @@ -0,0 +1,2 @@ +title: Lists +status: wip diff --git a/src/components/atoms/list/_list.twig b/src/components/atoms/list/_list.twig new file mode 100644 index 0000000..08f46c7 --- /dev/null +++ b/src/components/atoms/list/_list.twig @@ -0,0 +1,30 @@ +{# + # List atom + # + # @param text {string} - Required heading text. + #} + +

There’s Unordered Lists

+ + +

Ordered Lists

+
    +
  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  2. +
  3. Aliquam tincidunt mauris eu risus.
  4. +
  5. Vestibulum auctor dapibus neque.
  6. +
+ +

And Definition Lists

+
+
Definition list
+
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea +commodo consequat.
+
Lorem ipsum dolor sit amet
+
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna +aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea +commodo consequat.
+
diff --git a/src/components/atoms/notification-inline/notification-inline.config.yml b/src/components/atoms/notification-inline/notification-inline.config.yml new file mode 100644 index 0000000..c64e775 --- /dev/null +++ b/src/components/atoms/notification-inline/notification-inline.config.yml @@ -0,0 +1,16 @@ +title: "Notification Inline" +status: ready +context: + message: This is an inline notification + +variants: + - + name: has-error + context: + message: Something is wrong with this input + state: error + - + name: has-success + context: + message: You've entered the correct value for this input + state: success diff --git a/src/components/atoms/notification-inline/notification-inline.twig b/src/components/atoms/notification-inline/notification-inline.twig new file mode 100644 index 0000000..763d573 --- /dev/null +++ b/src/components/atoms/notification-inline/notification-inline.twig @@ -0,0 +1 @@ +
{{ message }}
diff --git a/src/components/atoms/paragraph/_paragraph.postcss b/src/components/atoms/paragraph/_paragraph.postcss new file mode 100644 index 0000000..b36d1f5 --- /dev/null +++ b/src/components/atoms/paragraph/_paragraph.postcss @@ -0,0 +1,31 @@ +/* ========================================================================== + PARAGRAPHS + ========================================================================== */ + +p { + @apply leading-normal; + + /* Turn on kerning, common ligatures and contextual alternates. */ + font-feature-settings: "clig", "kern", "liga"; + orphans: 3; + widows: 3; + + /* Sup desktop users? */ + @screen lg { + @apply text-md; + } +} + +/* An embiggening treatment applied to the lead paragraph. More lead. */ +.lede p:first-of-type { + @apply + text-md; + + /* Sup desktop users? */ + @screen lg { + @apply + leading-relaxed + mt-double + text-lg; + } +} diff --git a/src/components/atoms/paragraph/paragraph.config.yml b/src/components/atoms/paragraph/paragraph.config.yml new file mode 100644 index 0000000..fa36cf5 --- /dev/null +++ b/src/components/atoms/paragraph/paragraph.config.yml @@ -0,0 +1,13 @@ +title: Paragraphs +status: ready +context: + text: 'Donec vel sodales ligula, at vulputate tortor. Mauris vulputate mattis enim, id laoreet augue feugiat ut. + Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce consequat hendrerit risus, sed venenatis ipsum imperdiet vel. Pellentesque feugiat mauris sed commodo vulputate. Donec vel sodales ligula, at vulputate tortor.' + +variants: + - + name: Lede paragraphs + context: + class: lede + text: 'Paragraphs immediately following an H1 are styled as lede text. Donec vel sodales ligula, at vulputate tortor. Mauris vulputate mattis enim, id laoreet augue feugiat ut. + Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce consequat hendrerit risus, sed venenatis ipsum imperdiet vel. Pellentesque feugiat mauris sed commodo vulputate. Donec vel sodales ligula, at vulputate tortor.' diff --git a/src/components/atoms/paragraph/paragraph.twig b/src/components/atoms/paragraph/paragraph.twig new file mode 100644 index 0000000..14f1dda --- /dev/null +++ b/src/components/atoms/paragraph/paragraph.twig @@ -0,0 +1,12 @@ +{# + # Paragraph atom + # + # @param {string} text - text + #} + +{# Output #} +
+

+ {{ text }} +

+
diff --git a/src/components/atoms/radio-group/radio-group.config.yml b/src/components/atoms/radio-group/radio-group.config.yml new file mode 100644 index 0000000..798ec0e --- /dev/null +++ b/src/components/atoms/radio-group/radio-group.config.yml @@ -0,0 +1,6 @@ +title: "Radio Group" +status: prototype + +context: + name: radio-group + label: Radio option diff --git a/src/components/atoms/radio-group/radio-group.twig b/src/components/atoms/radio-group/radio-group.twig new file mode 100644 index 0000000..e9274e1 --- /dev/null +++ b/src/components/atoms/radio-group/radio-group.twig @@ -0,0 +1,31 @@ + +
+ A group of radios can be labelled using legend + + + + + + + +
\ No newline at end of file diff --git a/src/components/atoms/radio/_radio.postcss b/src/components/atoms/radio/_radio.postcss new file mode 100644 index 0000000..d4a7c17 --- /dev/null +++ b/src/components/atoms/radio/_radio.postcss @@ -0,0 +1,72 @@ +/* ========================================================================== + RADIOS + ========================================================================== */ + +.radio { + + @apply font-bold text-lg; + + /* Hide the real radio */ + & input { + @apply + absolute + opacity-0 + ; + } + + /* Create a faux radio */ + & .radio__label { + @apply + bg-white + border + flex items-center + h-full w-full + justify-center + p-4 + ; + + &:hover, + &:focus, + &:active { + + } + } + + /* Update the faux radio styles on checked and focussed states */ + & input:checked + .radio__label, + & input:focus + .radio__label { + @apply border-2; + } + + /* Apply disabled radio styles to the faux radio */ + & input:disabled + .radio__label { + &::before, + &::after, + & + .radio__label { + @apply cursor-not-allowed text-grey; + } + } +} + +/* SPECIALE SPICY STYLES */ +.radio__lightswitch { + + /* Lightswitch? */ + .radio__label { + @apply px-8; + + @screen lg { + @apply px-16; + } + } + + /* Switch on */ + & input:checked + .radio__label { + @apply bg-green text-white; + } + + /* Switch off */ + & input:not(:checked) + .radio__label { + @apply text-green; + } +} diff --git a/src/components/atoms/radio/radio.config.yml b/src/components/atoms/radio/radio.config.yml new file mode 100644 index 0000000..c0c0ace --- /dev/null +++ b/src/components/atoms/radio/radio.config.yml @@ -0,0 +1,21 @@ +title: "Radio" +status: prototype + +context: + name: radio + label: A Radio Example + id: 1 + +variants: + - + name: checked + context: + checked: true + label: A Checked Radio + id: 2 + - + name: disabled + context: + label: A Disabled Radio + id: 3 + disabled: true diff --git a/src/components/atoms/radio/radio.twig b/src/components/atoms/radio/radio.twig new file mode 100644 index 0000000..00d9929 --- /dev/null +++ b/src/components/atoms/radio/radio.twig @@ -0,0 +1,10 @@ + + diff --git a/src/components/atoms/rule/_rule.postcss b/src/components/atoms/rule/_rule.postcss new file mode 100644 index 0000000..47f8bf1 --- /dev/null +++ b/src/components/atoms/rule/_rule.postcss @@ -0,0 +1,7 @@ +/* ========================================================================== + HORIZONTAL RULES + ========================================================================== */ + +.hr { + @apply py-base text-mercury; +} diff --git a/src/components/atoms/rule/rule.config.yml b/src/components/atoms/rule/rule.config.yml new file mode 100644 index 0000000..8752016 --- /dev/null +++ b/src/components/atoms/rule/rule.config.yml @@ -0,0 +1,2 @@ +title: Horizontal Rule +status: ready diff --git a/src/components/atoms/rule/rule.twig b/src/components/atoms/rule/rule.twig new file mode 100644 index 0000000..94887d4 --- /dev/null +++ b/src/components/atoms/rule/rule.twig @@ -0,0 +1,9 @@ +{# + # Horizontal rule component + # + # @param class {string} - Optional component class. + #} + +{% set blockClass = blockClass | default() %} + +
diff --git a/src/components/atoms/select/_select.postcss b/src/components/atoms/select/_select.postcss new file mode 100644 index 0000000..c4cdba1 --- /dev/null +++ b/src/components/atoms/select/_select.postcss @@ -0,0 +1,59 @@ +/* ========================================================================== + SELECTS + ========================================================================== */ + +.select { + @apply + bg-white + border + flex + items-center + min-h-input + relative + ; + + @screen md { + @apply min-w-input; + } + + &:hover { + @apply border-blue; + } + + select { + @apply + absolute + appearance-none + bg-transparent + border-transparent + bottom-0 + p-2 + top-0 + w-full + ; + + /* hide ie drop-down arrow */ + &::-ms-expand { + @apply hidden; + } + + /* undo the firefox inner focus ring */ + &:focus:-moz-focusring { + @apply text-transparent; + + text-shadow: 0 0 0 #525252; + } + } + + .select__icon { + @apply + absolute + pointer-events-none + rotate-180 + transform + w-4 + ; + + right: 1em; + } +} diff --git a/src/components/atoms/select/select.config.yml b/src/components/atoms/select/select.config.yml new file mode 100644 index 0000000..48338d8 --- /dev/null +++ b/src/components/atoms/select/select.config.yml @@ -0,0 +1,28 @@ +title: "Select" +status: prototype +context: + name: select + id: ID + label: Even a select needs a label + options: + - + title: Option one + id: 1 + - + title: Option two + id: 2 + - + title: Option three + id: 3 + - + title: Option four + id: 4 + +variants: + - + name: required + context: + required: required + fieldname: required-select + label: This field is validated on submission. + notification: We do need you to make a selection. diff --git a/src/components/atoms/select/select.twig b/src/components/atoms/select/select.twig new file mode 100644 index 0000000..2dc69a2 --- /dev/null +++ b/src/components/atoms/select/select.twig @@ -0,0 +1,34 @@ + +{% if label %} + {% include '@label' with { + class: labelClass|default(null), + for: id, + label: label, + state: labelState|default(), + } only %} +{% endif %} +
+ + + {% spaceless %} + {%- include '@icon' with { + class: 'flex-none inline-block mr-4 text-currentColor w-4 pointer-events-none', + icon: 'chevron', + } only -%} + {% endspaceless %} +
+{% if notification|default() %} + {% include '@notification-inline' with { + message: notification, + state: noteState, + } only %} +{% endif %} diff --git a/src/components/atoms/small/_small.postcss b/src/components/atoms/small/_small.postcss new file mode 100644 index 0000000..7c905e5 --- /dev/null +++ b/src/components/atoms/small/_small.postcss @@ -0,0 +1,7 @@ +/* ========================================================================== + SMALL + ========================================================================== */ + +small { + @apply leading-default text-xs; +} diff --git a/src/components/atoms/small/small.config.yml b/src/components/atoms/small/small.config.yml new file mode 100644 index 0000000..b579b1e --- /dev/null +++ b/src/components/atoms/small/small.config.yml @@ -0,0 +1,4 @@ +title: Small +status: ready +context: + text: The small tag is to be used for legal text, like copyright notices or disclaimers. diff --git a/src/components/atoms/small/small.twig b/src/components/atoms/small/small.twig new file mode 100644 index 0000000..6e82c99 --- /dev/null +++ b/src/components/atoms/small/small.twig @@ -0,0 +1,11 @@ +{# + # Small atom + # + # @param text {string} - Required legal text. + #} + +{# Params #} +{% set text = text | default('') %} + +{# Output #} +{{ text }} diff --git a/src/components/atoms/textarea/textarea.config.yml b/src/components/atoms/textarea/textarea.config.yml new file mode 100644 index 0000000..3d4072c --- /dev/null +++ b/src/components/atoms/textarea/textarea.config.yml @@ -0,0 +1,20 @@ +title: "Text area" +status: prototype + +context: + message: + rows: 5 + name: textarea + placeholder: Enter your message here… + +variants: + - + name: has-error + context: + state: error + message: This field cannot be blank. Please enter a question. + - + name: has-success + context: + content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus suscipit lorem mollis ante dapibus, eu mollis ipsum porta. In in diam at augue faucibus bibendum vitae in risus. Aliquam vehicula luctus augue vitae consectetur. Aenean eu laoreet magna, blandit congue velit. Pellentesque maximus, mi sit amet ultricies tempor, arcu leo feugiat sem, a dictum purus ligula vitae nunc. Mauris vel purus dapibus, consectetur nibh ut, egestas sapien. + state: success diff --git a/src/components/atoms/textarea/textarea.twig b/src/components/atoms/textarea/textarea.twig new file mode 100644 index 0000000..706a10e --- /dev/null +++ b/src/components/atoms/textarea/textarea.twig @@ -0,0 +1,20 @@ +
+ +
+ + {% if state %} + + {% if state == 'error' %}×{% elseif state == 'success' %}✓{% endif %} + + {% endif %} +
+ {% if message %} + {% include '@notification-inline' %} + {% endif %} +
diff --git a/src/components/molecules/input-group/input-group.config.yml b/src/components/molecules/input-group/input-group.config.yml new file mode 100644 index 0000000..7dddfb1 --- /dev/null +++ b/src/components/molecules/input-group/input-group.config.yml @@ -0,0 +1,54 @@ +title: "Input Group" +status: ready +context: + label: For a11y reasons inputs should always have labels. + type: text + +variants: + - + name: With placeholder text + context: + fieldname: text-field + label: This is a label with placeholder text. + message: A Label Example, + placeholder: Placeholder text can confuse and frustrate users, it’s best avoided + - + name: With Notification + context: + fieldname: text-with-notes + label: This field may need explanation, see notes below. + notification: This is a inline notification message which can be used to display instructions or error messages + - + name: With Error Feedback + context: + inputState: error + fieldname: text-with-error + label: This field is validated on submission. + labelState: error + notification: Something is wrong with the data you entered. Please fix it. + noteState: error + - + name: With Success Feedback + context: + inputState: success + fieldname: text-with-sucess + label: This field is validated before submission. Snazzy. + notification: Good work, the form got exactly whatit needed! + noteState: success + value: You can still go back and change this content… + - + name: With Readonly Content + context: + fieldname: text-with-content + label: Your Name + notification: Sorry, you can't change this now. + readonly: readonly + value: Will Smith + - + name: With Disabled Input + context: + disabled: disabled + fieldname: date-disabled + label: Birth Date + notification: This form field has been disabled. + type: date \ No newline at end of file diff --git a/src/components/molecules/input-group/input-group.twig b/src/components/molecules/input-group/input-group.twig new file mode 100644 index 0000000..66f6ab2 --- /dev/null +++ b/src/components/molecules/input-group/input-group.twig @@ -0,0 +1,24 @@ +
+ {% if label %} + {% include '@label' with { + for: fieldname, + label: label, + state: labelState, + } only %} + {% endif %} + {% include '@input' with { + disabled: disabled, + id: fieldname, + placeholder: placeholder, + readonly: readonly, + state: inputState, + type: type, + value: value, + } only %} + {% if notification %} + {% include '@notification-inline' with { + message: notification, + state: noteState, + } only %} +{% endif %} +
diff --git a/src/components/molecules/logo/logo.config.yml b/src/components/molecules/logo/logo.config.yml new file mode 100644 index 0000000..e279145 --- /dev/null +++ b/src/components/molecules/logo/logo.config.yml @@ -0,0 +1,2 @@ +title: Logo +status: wip diff --git a/src/components/molecules/logo/logo.twig b/src/components/molecules/logo/logo.twig new file mode 100644 index 0000000..7251f15 --- /dev/null +++ b/src/components/molecules/logo/logo.twig @@ -0,0 +1,27 @@ + +{# + # Site logo + # + # @param blockClass {string} - Optional component classes. + # @param siteName {string} - Required site name. + # @param siteUrl {string} - Required base Url for the site. + #} + +{# Params #} +{% set blockClass = blockClass | default('w-auto') %} +{% set siteName = siteName | default('Kind') %} +{% set siteUrl = siteUrl | default('/') %} + +{# Output #} +
+ + + {% include '@icon' with { + class: 'max-w-logo', + height: '90', + icon: 'logo', + width: '180', + } only %} +
diff --git a/src/components/molecules/meta/_meta.postcss b/src/components/molecules/meta/_meta.postcss new file mode 100644 index 0000000..e5a8475 --- /dev/null +++ b/src/components/molecules/meta/_meta.postcss @@ -0,0 +1,19 @@ +/* ========================================================================== + META + ========================================================================== */ + +.meta { + @apply + flex flex-wrap items-center + -mx-2 -my-1 + leading-none; +} + +.meta__item { + @apply + mx-2 my-1 + text-xs + tracking-wider + uppercase + ; +} diff --git a/src/components/molecules/meta/meta.config.yml b/src/components/molecules/meta/meta.config.yml new file mode 100644 index 0000000..ecd7017 --- /dev/null +++ b/src/components/molecules/meta/meta.config.yml @@ -0,0 +1,14 @@ +title: Meta +status: ready +context: + items: + - + title: User-centred design + - + url: '/blog' + title: A link +variants: + - + name: With date + context: + dateVal: now diff --git a/src/components/molecules/meta/meta.twig b/src/components/molecules/meta/meta.twig new file mode 100644 index 0000000..75a749c --- /dev/null +++ b/src/components/molecules/meta/meta.twig @@ -0,0 +1,51 @@ +{# + # Meta component + # + # @param items {array} required array of strings or items + # @param item.url {string} optional - Uri of a linked meta item. + # @param item.text {string} optional - Text for each meta item. + + # @param dateVal {string|date} optional - Date to output as last meta item + + # @param opts {object} optional + # @param opts.contentClass {string} optional classname to apply to wrapping el + # @param opts.showLinks {boolean} optional force enable/disable linking items +#} + +{# Params #} +{% set items = items | default([]) %} +{% set dateVal = dateVal | default(null) %} + +{# default options #} +{%- set defaults = { + contentClass: '', + showLinks: true, +} -%} + +{%- set opts = defaults | merge(opts | default({})) -%} + +{%- if items or dateVal -%} +
+ {# Output #} + +
+{% endif %} diff --git a/src/components/molecules/nav/README.md b/src/components/molecules/nav/README.md new file mode 100644 index 0000000..d181d62 --- /dev/null +++ b/src/components/molecules/nav/README.md @@ -0,0 +1,4 @@ +## Nav - Data API +``` +@optional class - string - Additional classes +``` diff --git a/src/components/molecules/nav/nav.config.yml b/src/components/molecules/nav/nav.config.yml new file mode 100644 index 0000000..4f9b408 --- /dev/null +++ b/src/components/molecules/nav/nav.config.yml @@ -0,0 +1,20 @@ +title: Primary Navigation +status: ready +context: + navItems: + - + url: /about + title: About + isCurrent: true + - + url: /work + title: Work + isCurrent: + - + url: /team + title: Team + isCurrent: + - + url: /blog + title: Blog + isCurrent: diff --git a/src/components/molecules/nav/nav.twig b/src/components/molecules/nav/nav.twig new file mode 100644 index 0000000..1ea63d7 --- /dev/null +++ b/src/components/molecules/nav/nav.twig @@ -0,0 +1,20 @@ +{# + # Nav atom + # + # @param navItems {array} - Required primary navigation items. + # @param navClass {string} - Optional classes for modifying the nav object. + #} + +{% set navItems = navItems | default([]) %} + + diff --git a/src/components/molecules/pagination/pagination.config.yml b/src/components/molecules/pagination/pagination.config.yml new file mode 100644 index 0000000..62eaa63 --- /dev/null +++ b/src/components/molecules/pagination/pagination.config.yml @@ -0,0 +1,7 @@ +title: Pagination +status: ready +context: + pageInfo: + currentPage: 3 + prevUrl: / + nextUrl: / diff --git a/src/components/molecules/pagination/pagination.twig b/src/components/molecules/pagination/pagination.twig new file mode 100644 index 0000000..ff97ed2 --- /dev/null +++ b/src/components/molecules/pagination/pagination.twig @@ -0,0 +1,52 @@ +{# + # Horizontal rule component + # + # @param pageInfo {object} - Craft entries, paginated. + #} + +{% set pageInfo = pageInfo | default() %} + + diff --git a/src/components/organisms/prose/_prose.postcss b/src/components/organisms/prose/_prose.postcss new file mode 100644 index 0000000..8189944 --- /dev/null +++ b/src/components/organisms/prose/_prose.postcss @@ -0,0 +1,131 @@ +/* ========================================================================== + PROSE - Longform content, the stuff we hope someone else will write! + ========================================================================== */ + +.prose { + + figure { + @apply my-8; + } + + /* Headings need some space */ + h2, + h3, + h4, + h5, + h6 { + @apply mt-12 mb-4; + } + + /* Lists */ + & > dl, + & > ol, + & > ul { + @apply my-8; + + @screen lg { + @apply text-md; + } + } + + /* Listy lists */ + & > ol, + & > ul { + + @apply leading-snug; + + & > li { + @apply pl-6 relative; + + /* Faux list markers */ + &::before { + @apply + absolute + left-0 + ; + } + } + } + + /* Ordered lists */ + & > ol { + counter-reset: list-counter; + + & > li { + counter-increment: list-counter; + + /* Faux numero */ + &::before { + @apply text-teal; + + content: counter(list-counter) '.'; + } + } + } + + /* Unordered lists */ + & > ul > li { + /* Faux bullets */ + &::before { + @apply + bg-teal + block + h-2 w-2 + ; + + top: 0.5rem; + content: ''; + } + } + + li + li { + /* Space between list items */ + @apply mt-4; + } + + p { + + p { + @apply mt-4; + } + + @screen lg { + @apply text-md; + } + } + + /* base blockquote */ + blockquote { + @apply + relative + text-5xl + font-bold + leading-snug + ; + + &::before { + content: '“'; + } + + &::after { + content: '”'; + } + + } + + code, + pre { + @apply + font-mono + subpixel-antialiased + ; + + } +} + +/* Embiggened texty */ +.lede { + @apply + leading-snug + text-xl + ; +} diff --git a/src/components/organisms/prose/prose.config.yml b/src/components/organisms/prose/prose.config.yml new file mode 100644 index 0000000..cd188f0 --- /dev/null +++ b/src/components/organisms/prose/prose.config.yml @@ -0,0 +1,2 @@ +title: Typography +status: wip diff --git a/src/components/organisms/prose/prose.twig b/src/components/organisms/prose/prose.twig new file mode 100644 index 0000000..a4d87c9 --- /dev/null +++ b/src/components/organisms/prose/prose.twig @@ -0,0 +1,153 @@ +
+

Typography tester

+

Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.

+

By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you really are just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.

+

We get lots of complaints about it actually, with people regularly asking us things like:

+
+

Why is Tailwind removing the default styles on my h1 elements? How do I disable this? What do you mean I lose all the other base styles too?

+
+

We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a p element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look awesome, not awful.

+

This is our attempt to give you what you actually want, without any of the downsides of doing something stupid like disabling our base styles.

+

It adds a new prose class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:

+

What to expect from here on out

+

What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like bold text, unordered lists, ordered lists, code blocks, block quotes, and even italics.

+

It's important to cover all of these use cases for a few reasons:

+
    +
  1. We want everything to look good out of the box.
  2. +
  3. Really just the first reason, that's the whole point of the plugin.
  4. +
  5. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.
  6. +
+

Now we're going to try out another header style.

+

Typography should be easy

+

So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable.

+

Something a wise person once told me about typography is:

+
+

Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.

+
+

It's probably important that images look okay here by default as well:

+
+ +
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
+

Now I'm going to show you an example of an unordered list to make sure that looks good, too:

+ +

And that's the end of this section.

+

What if we stack headings?

+

We should make sure that looks good, too.

+

Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.

+

When a heading comes after a paragraph…

+

When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.

+ +

After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.

+

Code should look okay by default.

+

I think most people are going to use highlight.js or Prism or something if they want to style their code blocks but it wouldn't hurt to make them look okay out of the box, even with no syntax highlighting.

+

Here's what a default tailwind.config.js file looks like at the time of writing:

+
+    module.exports = {
+    purge: [],
+    theme: {
+      extend: {},
+    },
+    variants: {},
+    plugins: [],
+  }
+    
+  
+

Hopefully that looks good enough to you.

+

What about nested lists?

+

Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.

+
    +
  1. Nested lists are rarely a good idea. +
      +
    • You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read.
    • +
    • Nested navigation in UIs is a bad idea too, keep things as flat as possible.
    • +
    • Nesting tons of folders in your source code is also not helpful.
    • +
    +
  2. Since we need to have more items, here's another one. +
      +
    • I'm not sure if we'll bother styling more than two levels deep.
    • +
    • Two is already too much, three is guaranteed to be a bad idea.
    • +
    • If you nest four levels deep you belong in prison.
    • +
    +
  3. +
  4. Two items isn't really a list, three is good though. +
      +
    • Again please don't nest lists if you want people to actually read your content.
    • +
    • Nobody wants to look at this.
    • +
    • I'm upset that we even have to bother styling this.
    • +
    +
  5. +
+

The most annoying thing about lists in Markdown is that <li> elements aren't given a child <p> tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.

+ +

And finally a sentence to close off this section.

+

There are other elements we need to style

+

I almost forgot to mention links, like this link to the Tailwind CSS website. We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.

+

We even included table styles, check it out:

+ + + + + + + + + + + +
WrestlerOriginFinisher
Bret "The Hitman" HartCalgary, ABSharpshooter
Stone Cold Steve AustinAustin, TXStone Cold Stunner
Randy SavageSarasota, FLElbow Drop
VaderBoulder, COVader Bomb
Razor RamonChuluota, FLRazor's Edge
+

We also need to make sure inline code looks good, like if I wanted to talk about <span> elements or tell you the good news about @tailwindcss/typography.

+

Sometimes I even use code in headings

+

Even though it's probably a bad idea, and historically I've had a hard time making it look good. This "wrap the code blocks in backticks" trick works pretty well though really.

+

Another thing I've done in the past is put a code tag inside of a link, like if I wanted to tell you about the tailwindcss/docs repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.

+

We haven't used an h4 yet

+

But now we have. Please don't use h5 or h6 in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a before pseudo-element to scream at you if you use an h5 or h6.

+

We don't style them at all out of the box because h4 elements are already so small that they are the same size as the body copy. What are we supposed to do with an h5, make it smaller than the body copy? No thanks.

+

We still need to think about stacked headings though.

+

Let's make sure we don't screw that up with h4 elements, either.

+

Phew, with any luck we have styled the headings above this text and they look pretty good.

+

Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.

+

What I've written here is probably long enough, but adding this final sentence can't hurt.

+