Skip to content

Commit 0c35764

Browse files
committed
feat: initial setup and a couple of component docs
1 parent c6f1542 commit 0c35764

10 files changed

Lines changed: 6247 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
3+
# 11ty output directory
4+
_site

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.11.0

_layouts/component.webc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: default.webc
3+
---
4+
5+
<h1 @text="title"></h1>
6+
7+
<div @raw="content"></div>

_layouts/default.webc

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6+
7+
<title @text="title">Interfacez</title>
8+
<meta name="description" :content="description">
9+
10+
<!---
11+
@TODO: Favicon
12+
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png">
13+
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
14+
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
15+
<link rel="manifest" href="/assets/icons/site.webmanifest">
16+
<link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#0066ff">
17+
<link rel="shortcut icon" href="/assets/icons/favicon.ico">
18+
<meta name="msapplication-TileColor" content="#ffffff">
19+
<meta name="msapplication-config" content="/assets/icons/browserconfig.xml">
20+
<meta name="theme-color" content="#ffffff">
21+
-->
22+
23+
<!---
24+
@TODO: Share cards
25+
26+
<meta property="og:url" content="https://diamond.etch.co"/>
27+
<meta property="og:site_name" content="Diamond UI"/>
28+
<meta property="og:title" :content="title"/>
29+
<meta property="og:description" :content="description"/>
30+
31+
<meta property="og:image" content="https://diamond.etch.co/assets/images/share-cards/large.png"/>
32+
<meta property="og:image:type" content="image/png"/>
33+
<meta property="og:image:width" content="1200"/>
34+
<meta property="og:image:height" content="630"/>
35+
<meta property="og:image:alt" content="Diamond UI - Bring clarity to your components"/>
36+
37+
<meta property="og:image" content="https://diamond.etch.co/assets/images/share-cards/medium.png"/>
38+
<meta property="og:image:type" content="image/png"/>
39+
<meta property="og:image:width" content="600"/>
40+
<meta property="og:image:height" content="314"/>
41+
<meta property="og:image:alt" content="Diamond UI - Bring clarity to your components"/>
42+
43+
<meta property="og:image" content="https://diamond.etch.co/assets/images/share-cards/small.png"/>
44+
<meta property="og:image:type" content="image/png"/>
45+
<meta property="og:image:width" content="400"/>
46+
<meta property="og:image:height" content="400"/>
47+
<meta property="og:image:alt" content="Diamond UI - Bring clarity to your components"/>
48+
49+
<meta name="twitter:card" content="summary"/>
50+
<meta name="twitter:site" content="@etch"/>
51+
<meta name="twitter:creator" content="@etch"/>
52+
--->
53+
54+
<!---
55+
@TODO: Bundled base styles?
56+
<link rel="stylesheet" href="../styles/reset.css" webc:bucket="styles">
57+
<link rel="stylesheet" href="../styles/base.css" webc:bucket="styles">
58+
<link rel="stylesheet" :href="getBundleFileUrl('css', 'styles')" webc:keep>
59+
--->
60+
61+
<!--- Bundled 11ty:webc component styles --->
62+
<link rel="stylesheet" :href="getBundleFileUrl('css')" webc:keep>
63+
64+
<!---
65+
@TODO: Add umami
66+
<script
67+
webc:if="process.env.NODE_ENV === 'production'"
68+
src="https://eu.umami.is/script.js"
69+
data-website-id=""
70+
defer
71+
webc:keep
72+
></script>
73+
--->
74+
</head>
75+
<body>
76+
<header>
77+
<a href="/">InterfAceZ</a>
78+
</header>
79+
80+
<main @raw="content"></main>
81+
82+
<!--- Bundled 11ty:webc component scripts --->
83+
<script :src="getBundleFileUrl('js')" webc:keep></script>
84+
</body>
85+
</html>

eleventy.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import webc from "@11ty/eleventy-plugin-webc";
2+
3+
export default function(eleventyConfig) {
4+
eleventyConfig.setLayoutsDirectory("_layouts");
5+
eleventyConfig.addPlugin(webc);
6+
};

index.webc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: default.webc
3+
---
4+
5+
<ul>
6+
<li webc:for="component of $data.collections.component">
7+
<a :href="component.url" @text="component.data.title"></a>
8+
</li>
9+
</ul>

input-size/index.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
tags: component
3+
layout: component.webc
4+
title: Input size
5+
---
6+
7+
A utility class for sizing form fields appropriately.
8+
9+
<article aria-label="Component example">
10+
<input placeholder="Large" class="input-size-lg" />
11+
<input placeholder="Medium" class="input-size-md" />
12+
<input placeholder="Small" class="input-size-sm" />
13+
<input placeholder="Custom" class="input-size" style="--input-size: 50ch" />
14+
</article>
15+
16+
## Installation
17+
18+
### Manual
19+
20+
1. [Copy the CSS code](#)
21+
2. Include it in your websites CSS
22+
23+
### NPM
24+
25+
1. Install the library `npm install @etchteam/interfacez`
26+
2. Import the CSS `@import url('node_modules/@etchteam/interfacez/input-size/input-size.css);`
27+
28+
## Usage
29+
30+
Adding the class to your form fields will set their width.
31+
32+
```html
33+
<input class="input-size-md">
34+
```
35+
36+
A custom width can be provided by using the base class and modifying the CSS variable.
37+
38+
```html
39+
<input placeholder="Custom" class="input-size" style="--input-size: 50ch">
40+
```
41+
42+
## Recommendations
43+
44+
Form fields should be made as wide as the value that they should contain. This provides users with an indication of what the form expects them to enter.
45+
46+
The input should still be wide enough to accommodate the largest possible expected value.

money-input/index.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
tags: component
3+
layout: component.webc
4+
title: Money Input
5+
---
6+
7+
An input for collecting monetary values.
8+
9+
<article aria-label="Component example">
10+
<label for="cost">
11+
Amount in pounds
12+
</label>
13+
<az-money-input currency="£">
14+
<input id="cost" name="cost" />
15+
</az-money-input>
16+
</article>
17+
18+
## Installation
19+
20+
### Manual
21+
22+
1. [Copy the JS code](#)
23+
2. Include it in your websites JS
24+
25+
### NPM
26+
27+
1. Install the library `npm install @etchteam/interfacez`
28+
2. Import the JS `import '@etchteam/interfacez/money-input'`
29+
30+
## Usage
31+
32+
The web component should be added to your HTML by wrapping around an `<input>` element.
33+
34+
```html
35+
<az-money-input currency="£">
36+
<input id="cost" name="cost" />
37+
</az-money-input>
38+
```
39+
40+
This will provide:
41+
42+
- Input attributes
43+
- `type="text"`
44+
- `inputmode="decimal"`
45+
- `placeholder="0.00"`
46+
- Validation
47+
- No non-numeric values
48+
- Disallow more than two decimal places
49+
- Default required
50+
- A sensible max-width
51+
- A currency prop to prefix the input with a currency symbol
52+
53+
### Configuration
54+
55+
#### Max width
56+
57+
Use [input-size](/input-size) to override the max-width setting.
58+
59+
#### Currency
60+
61+
Providing `currency="£"` will prefix the input with “£”.
62+
63+
Remove the prop to provide a custom affix instead.
64+
65+
## Recommendations
66+
67+
### Affix the input
68+
69+
An input “affix” is the bit that goes either side of the field where users input their value.
70+
71+
For the majority of currency formats, a currency symbol or code can be added before the input as a “prefix”.
72+
73+
Affixing monetary inputs with the currency symbol is a quick win, it shows the expected currency and signals that a monetary value is expected.
74+
75+
The affix is especially helpful for mobile or touchscreen users, as it allows a numeric keyboard to be displayed so they can skip finding the currency symbol.
76+
77+
If users are expected to enter a value in a different currency, consider using a currency select box instead of a affix.
78+
79+
### Add a placeholder
80+
81+
A placeholder is a hint that appears in the input field before the user starts typing.
82+
83+
Monetary inputs are a good use-case for placeholders because they can show the expected format of the input, without affecting validity.
84+
85+
Use zero for the placeholder though – suggesting a price might be a bit cheeky.
86+
87+
### Size the input appropriately
88+
89+
Making the input as wide as the expected value indicates to users what they’re expected to enter.
90+
91+
The input should be wide enough to accommodate the largest possible value, so unless you anticipate users entering values in the millions, the input will probably be quite small.
92+
93+
### Use a "text" input type
94+
95+
We recommend using the type="text" attribute instead of type="number". The number input type is designed to capture non-decimal, incrementable numbers.
96+
97+
For example, entering "1.5" and either scrolling inside the input or clicking the up/down arrows that most browsers add to number type inputs, causes the number to be rounded up or down.
98+
99+
This isn’t good for monetary values where decimal place precision is usually crucial.
100+
101+
Additionally, the [Gov UK team identified several other usability and accessibility issues](https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/) to consider when using number inputs.
102+
103+
### Set the inputmode to "decimal"
104+
105+
This is an important step to ensure the correct keyboard is displayed on mobile devices.
106+
107+
For monetary values, we want a keyboard with numbers, a decimal point, and a comma to cover all possible currency formats.
108+
109+
We suggest using inputmode="decimal" instead of inputmode="numeric" because during testing we found that some IOS devices displayed a keypad that lacked a decimal point.
110+
111+
### Expect unexpected formats
112+
113+
Users will likely enter values in ways we don’t anticipate, but if the input isn’t technically wrong, we should avoid requiring them to amend it. Here are some possible formats to expect:
114+
115+
- Numbers with comma separators "1,000.00"
116+
- Including the currency symbol "£1,000.00"
117+
- Not including decimal places "10"
118+
119+
Including the currency code "1,000.00 GBP" or "GBP 1,000.00" might be going above and beyond, but could be worth considering if you’re expecting international users.
120+
121+
### Validate the input
122+
123+
Validation should catch:
124+
125+
- Non-numeric values (excluding the currency code mentioned above if applicable)
126+
- Values with more than two decimal places
127+
- Missing values if the field is required
128+
129+
You may want to consider if setting an maximum or minimum value limit is appropriate to warn the customer about before they submit the form.
130+
131+
### Remember to add a label
132+
133+
Labels should be added as well as the placeholder. It’s especially important for users of screen readers where the placeholder won't be announced.
134+
135+
*Read the full post on [etch.co/blog/money-input](https://etch.co/blog/money-input)*

0 commit comments

Comments
 (0)