Repository: LeaVerou/nudeui
Branch: main
Commit: dbaec1ec5dd1
Files: 57
Total size: 102.8 KB
Directory structure:
gitextract_w7vts8kx/
├── .eleventy.cjs
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── _headers
├── _includes/
│ └── page.njk
├── _redirects
├── assets/
│ └── global.js
├── elements/
│ ├── button-group/
│ │ ├── README.md
│ │ ├── button-group.js
│ │ ├── style.css
│ │ └── style.postcss
│ ├── cycle-toggle/
│ │ ├── README.md
│ │ ├── cycle-toggle.js
│ │ └── style.css
│ ├── data-bind/
│ │ ├── Observer.js
│ │ ├── README.md
│ │ ├── Recipe.js
│ │ ├── data-bind.js
│ │ ├── properties.js
│ │ └── util.js
│ ├── drop-down/
│ │ ├── README.md
│ │ ├── drop-down.js
│ │ └── style.css
│ ├── html-demo/
│ │ ├── README.md
│ │ ├── html-demo.css
│ │ └── html-demo.js
│ ├── img-input/
│ │ ├── README.md
│ │ ├── img-input.js
│ │ ├── style.css
│ │ └── test.html
│ ├── index.css
│ ├── index.js
│ ├── meter-discrete/
│ │ ├── README.md
│ │ ├── meter-discrete.js
│ │ └── style.css
│ ├── nd-calendar/
│ │ ├── README.md
│ │ ├── nd-calendar.js
│ │ ├── style.css
│ │ └── style.postcss
│ ├── nd-rating/
│ │ ├── README.md
│ │ └── nd-rating.js
│ ├── nd-slider/
│ │ ├── README.md
│ │ ├── nd-slider.css
│ │ └── nd-slider.js
│ ├── nd-switch/
│ │ ├── README.md
│ │ └── nd-switch.css
│ └── with-presets/
│ ├── README.md
│ ├── style.css
│ └── with-presets.js
├── package.json
├── postcss.config.cjs
├── style/
│ ├── forms.css
│ ├── tables.css
│ └── tokens.css
└── style.css
================================================
FILE CONTENTS
================================================
================================================
FILE: .eleventy.cjs
================================================
let markdownIt = require("markdown-it");
let markdownItAnchor = require("markdown-it-anchor");
let markdownItAttrs = require("markdown-it-attrs");
module.exports = config => {
let data = {
"layout": "page.njk",
"permalink": "{{ page.filePathStem | replace('README', '') }}/index.html",
eleventyComputed: {
defaultTitle: data => {
if (data.id) {
return data.css_only? `.${data.id}` : `<${data.id}>`;
}
return "Nude UI: A collection of accessible, customizable, ultra-light web components";
}
}
};
for (let p in data) {
config.addGlobalData(p, data[p]);
}
config.setDataDeepMerge(true);
config.setLibrary("md", markdownIt({
html: true,
})
.disable("code")
.use(markdownItAttrs)
.use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.headerLink(),
level: 2,
})
);
config.addFilter(
"relative",
page => {
let path = page.url.replace(/[^/]+$/, "");
let ret = require("path").relative(path, "/");
return ret || ".";
}
);
return {
markdownTemplateEngine: "njk",
templateFormats: ["md", "njk"],
dir: {
output: "."
},
};
};
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
================================================
FILE: .gitignore
================================================
index.html
nd-calendar/style.css
button-group/style.css
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2021 Lea Verou
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Nude UI
A collection of accessible, customizable, ultra-light web components
- Using built-in controls whenever possible, web components when JS and/or extra elements are needed
- Highly customizable
- Tiny (most are ~1KB minified & compressed)
A work in progress. Try them out and [provide feedback](https://github.com/leaverou/nudeui) or move along and check back later.
## Components
| Name | Tag | Description | Type(s) | Status |
|------|-----|-------------|-------------------|--------|
| [Switch](elements/nd-switch) | `` | On/off toggle switch | CSS-only | Mature |
| [Button Group](elements/button-group) | `` | Group of buttons for selecting one or more values out of a set of options | JS | Mature |
| [Cycle Toggle](elements/cycle-toggle) | `` | Compact way to select one option from a group, click selects the next option | JS | Mature |
| [Discrete meter](elements/meter-discrete) | `` | Meter with discrete values shown as icons | JS | Mature |
| [Rating](elements/nd-rating) | `` | Like discrete meter, but editable via hovering and clicking | JS | Mature |
| [HTML Demo](elements/html-demo) | `` | Display demos of HTML content alongside their source code | JS | Mature |
| [Image input](elements/img-input) | `` | Input an image via URL, file upload, drag-and-drop, or pasting | JS | In incubation |
| [Freeform text with presets](elements/with-presets) | `` | A combination of a text input and a select element | JS | In incubation |
| [Calendar](elements/nd-calendar) | `` | Show dates on a calendar | JS | In incubation |
| [Data bind](elements/data-bind) | `` | Declaratively bind data from a source element to a target element | JS | In incubation |
## Wanna use them all?
This includes all components marked as mature:
```js
import "https://nudeui.com/elements/index.js";
```
Components still being incubated will need to be included individually.
## Failed experiments
Do not use. These have serious flaws and are likely incomplete.
They are included here only in case someone else wants to look into fixing their issues,
as well as a warning for other wanderers going down the same path.
- [Drop down](elements/drop-down)
================================================
FILE: _headers
================================================
/*
Access-Control-Allow-Origin: *
================================================
FILE: _includes/page.njk
================================================
{{ title or defaultTitle }}
{% if css_only %}
{% elseif id %}
{% endif %}
{{ includes | safe }}
{{ content | safe }}
{% if id %}
Installation
{% if css_only %}
This is a CSS-only component. You can just import it straight into your CSS file:
@import url('https://nudeui.com/elements/{{ id }}/{{ id }}.css');
Then use class="{{ id }}" on the types of elements described above.
{% else %}
Just include the component's JS file and you're good:
<script src="https://nudeui.com/elements/{{ id }}/{{ id }}.js" type="module"></script>
In case you want to link to local files: CSS is fetched automatically, and assumed to be in the same directory as the JS file.
{% endif %}
{% endif %}
================================================
FILE: _redirects
================================================
/button-group/* /elements/button-group/:splat 301
/meter-discrete/* /elements/meter-discrete/:splat 301
/with-presets/* /elements/with-presets/:splat 301
/cycle-toggle/* /elements/cycle-toggle/:splat 301
/nd-:tag/* /elements/nd-:tag/:splat 301
================================================
FILE: assets/global.js
================================================
// Website scripts
import "../elements/index.js";
import "https://prismjs.com/prism.js";
import HTMLDemo from "../elements/html-demo/html-demo.js";
if (!document.documentElement.matches(".no-home-link")) {
let h1 = document.querySelector("h1");
if (h1 && !h1.parentNode.querySelector(".home")) {
h1.insertAdjacentHTML("beforebegin", `Nude UI`);
}
}
HTMLDemo.wrapAll();
================================================
FILE: elements/button-group/README.md
================================================
---
id: button-group
title:
includes: ''
---
# ``
Group of exclusive push buttons
## Features
- Uses existing button styling present in the page
- Uses [`ElementInternals`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) to work like a built-in form element
- Accessible
- Ultra light (3KB **unminified** and **uncompressed**!)
## Examples
Basic, no selected option:
```html
```
Providing values:
```html
```
Pre-selected state via `aria-pressed`:
```html
```
Multiple:
```html
```
Participates in form submission (requires [`ElementInternals`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) support):
```html
```
Vertical
```html
```
Separate
```html
```
Dynamically setting `element.value`:
```html
```
Dynamically adding `aria-pressed` attribute:
```html
```
Dynamically adding options:
```html
```
[WIP](https://twitter.com/LeonieWatson/status/1547544701036888065):
`` has an implicit ARIA Role of `region`, so adding an `aria-label` should make it work as a landmark out of the box
(requires [`ElementInternals`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) support):
```html
```
Regular labels should work too (requires [`ElementInternals`](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) support):
```html
```
You don't even need to use an actual `