@statistikzh/leu 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -0
- package/.eslintrc.json +27 -0
- package/.github/workflows/publish.yml +19 -0
- package/.github/workflows/release-please.yml +19 -0
- package/.github/workflows/test.yml +38 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/.storybook/main.js +11 -0
- package/.storybook/preview-head.html +5 -0
- package/.storybook/preview.js +23 -0
- package/CHANGELOG.md +63 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +31 -0
- package/LICENSE +21 -0
- package/README.md +170 -0
- package/commitlint.config.cjs +1 -0
- package/dist/Button-83c6df93.js +403 -0
- package/dist/Checkbox.js +144 -0
- package/dist/CheckboxGroup.js +82 -0
- package/dist/Chip-60af1402.js +162 -0
- package/dist/ChipGroup.js +79 -0
- package/dist/ChipLink.js +46 -0
- package/dist/ChipRemovable.js +43 -0
- package/dist/ChipSelectable.js +92 -0
- package/dist/Input.js +686 -0
- package/dist/Radio.js +156 -0
- package/dist/RadioGroup.js +194 -0
- package/dist/Select.js +859 -0
- package/dist/Table-72d305d7.js +506 -0
- package/dist/Table.js +8 -0
- package/dist/defineElement-47d4f665.js +15 -0
- package/dist/icon-b68c7e1e.js +202 -0
- package/dist/index.js +21 -0
- package/dist/leu-checkbox-group.js +6 -0
- package/dist/leu-checkbox.js +6 -0
- package/dist/leu-chip-group.js +5 -0
- package/dist/leu-chip-link.js +6 -0
- package/dist/leu-chip-removable.js +7 -0
- package/dist/leu-chip-selectable.js +6 -0
- package/dist/leu-input.js +9 -0
- package/dist/leu-radio-group.js +6 -0
- package/dist/leu-radio.js +5 -0
- package/dist/leu-select.js +12 -0
- package/dist/leu-table.js +10 -0
- package/dist/theme.css +51 -0
- package/index.js +10 -0
- package/package.json +85 -0
- package/postcss.config.cjs +14 -0
- package/rollup.config.js +54 -0
- package/scripts/generate-component/generate.js +167 -0
- package/scripts/generate-component/templates/[Name].js +33 -0
- package/scripts/generate-component/templates/[name].css +11 -0
- package/scripts/generate-component/templates/[namespace]-[name].js +3 -0
- package/scripts/generate-component/templates/stories/[name].stories.js +13 -0
- package/scripts/generate-component/templates/test/[name].test.js +22 -0
- package/src/components/button/Button.js +150 -0
- package/src/components/button/button.css +232 -0
- package/src/components/button/leu-button.js +3 -0
- package/src/components/button/stories/button.stories.js +333 -0
- package/src/components/button/test/button.test.js +22 -0
- package/src/components/button-group/ButtonGroup.js +63 -0
- package/src/components/button-group/button-group.css +10 -0
- package/src/components/button-group/leu-button-group.js +3 -0
- package/src/components/button-group/stories/button-group.stories.js +41 -0
- package/src/components/button-group/test/button-group.test.js +22 -0
- package/src/components/checkbox/Checkbox.js +142 -0
- package/src/components/checkbox/CheckboxGroup.js +80 -0
- package/src/components/checkbox/leu-checkbox-group.js +3 -0
- package/src/components/checkbox/leu-checkbox.js +3 -0
- package/src/components/checkbox/stories/checkbox-group.stories.js +52 -0
- package/src/components/checkbox/stories/checkbox.stories.js +43 -0
- package/src/components/checkbox/test/checkbox.test.js +101 -0
- package/src/components/chip/Chip.js +24 -0
- package/src/components/chip/ChipGroup.js +71 -0
- package/src/components/chip/ChipLink.js +45 -0
- package/src/components/chip/ChipRemovable.js +42 -0
- package/src/components/chip/ChipSelectable.js +91 -0
- package/src/components/chip/chip-group.css +5 -0
- package/src/components/chip/chip.css +130 -0
- package/src/components/chip/exports.js +10 -0
- package/src/components/chip/leu-chip-group.js +3 -0
- package/src/components/chip/leu-chip-link.js +3 -0
- package/src/components/chip/leu-chip-removable.js +3 -0
- package/src/components/chip/leu-chip-selectable.js +3 -0
- package/src/components/chip/stories/chip-group.stories.js +99 -0
- package/src/components/chip/stories/chip-link.stories.js +37 -0
- package/src/components/chip/stories/chip-removable.stories.js +28 -0
- package/src/components/chip/stories/chip-selectable.stories.js +46 -0
- package/src/components/chip/test/chip.test.js +22 -0
- package/src/components/dropdown/Dropdown.js +55 -0
- package/src/components/dropdown/dropdown.css +17 -0
- package/src/components/dropdown/leu-dropdown.js +3 -0
- package/src/components/dropdown/stories/dropdown.stories.js +25 -0
- package/src/components/dropdown/test/dropdown.test.js +31 -0
- package/src/components/icon/icon.js +201 -0
- package/src/components/input/Input.js +421 -0
- package/src/components/input/input.css +231 -0
- package/src/components/input/leu-input.js +3 -0
- package/src/components/input/stories/input.stories.js +185 -0
- package/src/components/input/test/input.test.js +22 -0
- package/src/components/menu/Menu.js +18 -0
- package/src/components/menu/MenuItem.js +95 -0
- package/src/components/menu/leu-menu-item.js +3 -0
- package/src/components/menu/leu-menu.js +3 -0
- package/src/components/menu/menu-item.css +72 -0
- package/src/components/menu/menu.css +14 -0
- package/src/components/menu/stories/menu-item.stories.js +51 -0
- package/src/components/menu/stories/menu.stories.js +21 -0
- package/src/components/menu/test/menu.test.js +22 -0
- package/src/components/pagination/Pagination.js +152 -0
- package/src/components/pagination/leu-pagination.js +3 -0
- package/src/components/pagination/pagination.css +49 -0
- package/src/components/pagination/stories/pagination.stories.js +82 -0
- package/src/components/pagination/test/pagination.test.js +22 -0
- package/src/components/radio/Radio.js +62 -0
- package/src/components/radio/RadioGroup.js +193 -0
- package/src/components/radio/leu-radio-group.js +3 -0
- package/src/components/radio/leu-radio.js +3 -0
- package/src/components/radio/radio.css +76 -0
- package/src/components/radio/stories/radio-group.stories.js +49 -0
- package/src/components/radio/stories/radio.stories.js +48 -0
- package/src/components/radio/test/radio.test.js +38 -0
- package/src/components/select/Select.js +350 -0
- package/src/components/select/leu-select.js +3 -0
- package/src/components/select/select.css +215 -0
- package/src/components/select/stories/select.stories.js +302 -0
- package/src/components/select/test/select.test.js +29 -0
- package/src/components/table/Table.js +301 -0
- package/src/components/table/leu-table.js +3 -0
- package/src/components/table/stories/table.stories.js +116 -0
- package/src/components/table/test/table.test.js +36 -0
- package/src/lib/defineElement.js +13 -0
- package/src/lib/hasSlotController.js +85 -0
- package/src/styles/custom-media.css +5 -0
- package/src/styles/custom-properties.css +51 -0
- package/src/styles/theme.css +1 -0
- package/stat_zh.png +0 -0
- package/stylelint.config.mjs +21 -0
- package/web-dev-server-storybook.config.mjs +19 -0
- package/web-test-runner.config.mjs +49 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-use-before-define */
|
|
3
|
+
|
|
4
|
+
import arg from "arg"
|
|
5
|
+
import fs from "fs"
|
|
6
|
+
import path from "path"
|
|
7
|
+
import { fileURLToPath } from "url"
|
|
8
|
+
|
|
9
|
+
const fsPromises = fs.promises
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
11
|
+
const __dirname = path.dirname(__filename)
|
|
12
|
+
|
|
13
|
+
const namespace = "leu"
|
|
14
|
+
const Namespace = "Leu"
|
|
15
|
+
|
|
16
|
+
const printHelp = () => {
|
|
17
|
+
console.log(`
|
|
18
|
+
Usage: ./scripts/generate-component/generate.js [options]
|
|
19
|
+
|
|
20
|
+
Options:
|
|
21
|
+
-n, --name Name of the component directory, camel-case (required)
|
|
22
|
+
-c, --components List of components to generate, camel-case (optional, defaults to name)
|
|
23
|
+
-h, --help Print this help message
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
./scripts/generate-component/generate.js --name radio --components radio,radio-button
|
|
27
|
+
./scripts/generate-component/generate.js -n select
|
|
28
|
+
`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const upperCamelCase = (str) =>
|
|
32
|
+
str
|
|
33
|
+
.split("-")
|
|
34
|
+
.map((chunk) => `${chunk.charAt(0).toUpperCase()}${chunk.slice(1)}`)
|
|
35
|
+
.join("")
|
|
36
|
+
|
|
37
|
+
const makeFolder = async (dir) => {
|
|
38
|
+
if (dir !== "." && !fs.existsSync(dir)) {
|
|
39
|
+
await fsPromises.mkdir(dir)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const formatTemplateFileContents = (replacements, content) => {
|
|
44
|
+
// replace all instances of [name], [Name], [namespace] and [Namespace] accordingly
|
|
45
|
+
let result = content
|
|
46
|
+
for (let i = 0; i < replacements.length; i += 1) {
|
|
47
|
+
const { regex, value } = replacements[i]
|
|
48
|
+
result = result.replace(regex, value)
|
|
49
|
+
}
|
|
50
|
+
return result
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const getReplacements = async ({ name }) => {
|
|
54
|
+
// name to lower-kebab-case (e.g. Text Input -> text-input)
|
|
55
|
+
// const lowerKebabCaseName = lowerKebabCase(name)
|
|
56
|
+
// name to UpperCamelCase (e.g. text-input -> TextInput)
|
|
57
|
+
const upperCamelCaseName = upperCamelCase(name)
|
|
58
|
+
|
|
59
|
+
return [
|
|
60
|
+
{ regex: /\[name\]/g, value: name },
|
|
61
|
+
{ regex: /\[namespace\]/g, value: namespace },
|
|
62
|
+
{ regex: /\[Namespace\]/g, value: Namespace },
|
|
63
|
+
{ regex: /\[Name\]/g, value: upperCamelCaseName },
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const copyFile = async (sourcePath, targetPath, params, replacements) => {
|
|
68
|
+
const stats = await fsPromises.stat(sourcePath)
|
|
69
|
+
if (stats.isDirectory()) {
|
|
70
|
+
await makeFolder(targetPath)
|
|
71
|
+
await copyAllFiles(sourcePath, targetPath, params)
|
|
72
|
+
} else if (stats.isFile()) {
|
|
73
|
+
const templateFileContents = await fsPromises.readFile(sourcePath, {
|
|
74
|
+
encoding: "utf8",
|
|
75
|
+
})
|
|
76
|
+
const formattedTemplateFileContents = formatTemplateFileContents(
|
|
77
|
+
replacements,
|
|
78
|
+
templateFileContents
|
|
79
|
+
)
|
|
80
|
+
await fsPromises.writeFile(targetPath, formattedTemplateFileContents, {
|
|
81
|
+
encoding: "utf8",
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
if (params.verbose) {
|
|
85
|
+
console.log(`Copied: ${sourcePath} -> ${targetPath}`)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const copyAllFiles = async (sourcePath, targetPath, params) => {
|
|
91
|
+
const fileNames = await fsPromises.readdir(sourcePath)
|
|
92
|
+
const fileCopyPromises = []
|
|
93
|
+
const replacements = await getReplacements(params)
|
|
94
|
+
fileNames.forEach((fileName) => {
|
|
95
|
+
const newFileName = formatTemplateFileContents(replacements, fileName)
|
|
96
|
+
|
|
97
|
+
console.log(`Creating: ${targetPath}/${newFileName}`)
|
|
98
|
+
|
|
99
|
+
fileCopyPromises.push(
|
|
100
|
+
copyFile(
|
|
101
|
+
`${sourcePath}/${fileName}`,
|
|
102
|
+
`${targetPath}/${newFileName}`,
|
|
103
|
+
params,
|
|
104
|
+
replacements
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
})
|
|
108
|
+
await Promise.all(fileCopyPromises)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const generate = async () => {
|
|
112
|
+
const args = arg({
|
|
113
|
+
"--help": Boolean,
|
|
114
|
+
"--name": String,
|
|
115
|
+
"--components": String,
|
|
116
|
+
"-n": "--name",
|
|
117
|
+
"-c": "--components",
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
if (args["--help"]) {
|
|
121
|
+
printHelp()
|
|
122
|
+
process.exit(0)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!args["--name"]) {
|
|
126
|
+
console.log("Please provide a name for your component.")
|
|
127
|
+
process.exit(1)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const name = args["--name"]
|
|
131
|
+
const components = args["--components"]
|
|
132
|
+
? args["--components"].split(",").map((component) => component.trim())
|
|
133
|
+
: [name]
|
|
134
|
+
|
|
135
|
+
const kebabCaseRegex = /^[a-z]+(-[a-z]+)*$/
|
|
136
|
+
|
|
137
|
+
if (![name].concat(components).every((c) => kebabCaseRegex.test(c))) {
|
|
138
|
+
console.log(
|
|
139
|
+
"The name and the components have to be in camel case and can only contain [a-z] letters."
|
|
140
|
+
)
|
|
141
|
+
console.log("Example: radio-group")
|
|
142
|
+
process.exit(1)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const destinationPath = path.join(process.cwd(), `src/components/${name}`)
|
|
146
|
+
const templatesPath = path.join(__dirname, "templates")
|
|
147
|
+
|
|
148
|
+
if (fs.existsSync(destinationPath)) {
|
|
149
|
+
console.log(`The component ${name} already exists.`)
|
|
150
|
+
process.exit(1)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await makeFolder(destinationPath)
|
|
154
|
+
|
|
155
|
+
const copyPromises = components.map(async (component) =>
|
|
156
|
+
copyAllFiles(templatesPath, destinationPath, {
|
|
157
|
+
name: component,
|
|
158
|
+
Name: upperCamelCase(component),
|
|
159
|
+
namespace,
|
|
160
|
+
Namespace,
|
|
161
|
+
})
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
await Promise.all(copyPromises)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
await generate()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { html, LitElement } from "lit"
|
|
2
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
3
|
+
import styles from "./[name].css"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @tagname [namespace]-[name]
|
|
7
|
+
*/
|
|
8
|
+
export class Leu[Name] extends LitElement {
|
|
9
|
+
static styles = styles
|
|
10
|
+
|
|
11
|
+
static shadowRootOptions = {
|
|
12
|
+
...LitElement.shadowRootOptions,
|
|
13
|
+
delegatesFocus: true,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static properties = {
|
|
17
|
+
value: { type: String },
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render() {
|
|
25
|
+
return html`
|
|
26
|
+
<p>Hello ${this.tagName}</p>
|
|
27
|
+
`
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function define[Name]Elements() {
|
|
32
|
+
defineElement("[name]", [Namespace][Name])
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import "../[namespace]-[name].js"
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "[Name]",
|
|
6
|
+
component: "[namespace]-[name]",
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function Template({}) {
|
|
10
|
+
return html` <[namespace]-[name] /> `
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Regular = Template.bind({})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect } from "@open-wc/testing"
|
|
3
|
+
|
|
4
|
+
import "../[namespace]-[name].js"
|
|
5
|
+
|
|
6
|
+
async function defaultFixture() {
|
|
7
|
+
return fixture(html` <[namespace]-[name] /> `)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
describe("[Namespace][Name]", () => {
|
|
11
|
+
it("is a defined element", async () => {
|
|
12
|
+
const el = await customElements.get("[namespace]-[name]")
|
|
13
|
+
|
|
14
|
+
await expect(el).not.to.be.undefined
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it("passes the a11y audit", async () => {
|
|
18
|
+
const el = await defaultFixture()
|
|
19
|
+
|
|
20
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { html, nothing, LitElement } from "lit"
|
|
2
|
+
import { classMap } from "lit/directives/class-map.js"
|
|
3
|
+
import { Icon } from "../icon/icon.js"
|
|
4
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
5
|
+
|
|
6
|
+
import styles from "./button.css"
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
Design: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=4-1444&mode=design&t=xu5Vii8jXKKCKDez-0
|
|
10
|
+
Live Demo: zh.ch
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const BUTTON_VARIANTS = ["primary", "secondary", "ghost"]
|
|
14
|
+
Object.freeze(BUTTON_VARIANTS)
|
|
15
|
+
export { BUTTON_VARIANTS }
|
|
16
|
+
|
|
17
|
+
const BUTTON_SIZES = ["normal", "small"]
|
|
18
|
+
Object.freeze(BUTTON_SIZES)
|
|
19
|
+
export { BUTTON_SIZES }
|
|
20
|
+
|
|
21
|
+
const BUTTON_TYPES = ["button", "submit", "reset"]
|
|
22
|
+
Object.freeze(BUTTON_TYPES)
|
|
23
|
+
export { BUTTON_TYPES }
|
|
24
|
+
|
|
25
|
+
export const BUTTON_EXPANDED_OPTIONS = ["open", "closed"]
|
|
26
|
+
Object.freeze(BUTTON_EXPANDED_OPTIONS)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @tagname leu-button
|
|
30
|
+
*/
|
|
31
|
+
export class LeuButton extends LitElement {
|
|
32
|
+
static styles = styles
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
static shadowRootOptions = {
|
|
38
|
+
...LitElement.shadowRootOptions,
|
|
39
|
+
delegatesFocus: true,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static properties = {
|
|
43
|
+
label: { type: String },
|
|
44
|
+
icon: { type: String },
|
|
45
|
+
iconAfter: { type: String },
|
|
46
|
+
size: { type: String },
|
|
47
|
+
variant: { type: String },
|
|
48
|
+
type: { type: String },
|
|
49
|
+
|
|
50
|
+
disabled: { type: Boolean },
|
|
51
|
+
round: { type: Boolean },
|
|
52
|
+
active: { type: Boolean },
|
|
53
|
+
inverted: { type: Boolean },
|
|
54
|
+
expanded: { type: String },
|
|
55
|
+
fluid: { type: Boolean },
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
constructor() {
|
|
59
|
+
super()
|
|
60
|
+
/** @type {string} */
|
|
61
|
+
this.label = null
|
|
62
|
+
/** @type {string} */
|
|
63
|
+
this.icon = null
|
|
64
|
+
/** @type {string} - Only taken into account if Label and no Icon is set */
|
|
65
|
+
this.iconAfter = null
|
|
66
|
+
/** @type {string} */
|
|
67
|
+
this.size = "normal"
|
|
68
|
+
/** @type {string} */
|
|
69
|
+
this.variant = "primary"
|
|
70
|
+
/** @type {string} */
|
|
71
|
+
this.type = "button"
|
|
72
|
+
|
|
73
|
+
/** @type {boolean} */
|
|
74
|
+
this.disabled = false
|
|
75
|
+
/** @type {boolean} - Only taken into account if no Label and an Icon is set */
|
|
76
|
+
this.round = false
|
|
77
|
+
/** @type {boolean} */
|
|
78
|
+
this.active = false
|
|
79
|
+
/** @type {boolean} - will be used on dark Background */
|
|
80
|
+
this.inverted = false
|
|
81
|
+
|
|
82
|
+
/** @type {boolean} - Alters the shape of the button to be full width of its parent container */
|
|
83
|
+
this.fluid = false
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Only taken into account if variant is "ghost"
|
|
87
|
+
* @type {("open" | "closed" | undefined)}
|
|
88
|
+
*/
|
|
89
|
+
this.expanded = undefined
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getIconSize() {
|
|
93
|
+
return this.size === "small" || this.variant === "ghost" ? 16 : 24
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
renderIconBefore() {
|
|
97
|
+
if (this.icon) {
|
|
98
|
+
return html`<div class="icon-wrapper icon-wrapper--before">
|
|
99
|
+
${Icon(this.icon, this.getIconSize())}
|
|
100
|
+
</div>`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return nothing
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
renderIconAfter() {
|
|
107
|
+
if (this.iconAfter && this.label && !this.icon) {
|
|
108
|
+
return html`<div class="icon-wrapper icon-wrapper--after">
|
|
109
|
+
${Icon(this.iconAfter, this.getIconSize())}
|
|
110
|
+
</div>`
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return nothing
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
renderExpandingIcon() {
|
|
117
|
+
if (typeof this.expanded !== "undefined" && this.variant === "ghost") {
|
|
118
|
+
return html`<div class="icon-wrapper icon-wrapper--expanded">
|
|
119
|
+
${Icon("angleDropDown", 24)}
|
|
120
|
+
</div>`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return nothing
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
render() {
|
|
127
|
+
const cssClasses = {
|
|
128
|
+
icon: !this.label && this.icon && !this.iconAfter,
|
|
129
|
+
round: !this.label && this.icon && !this.iconAfter && this.round,
|
|
130
|
+
active: this.active,
|
|
131
|
+
inverted: this.inverted,
|
|
132
|
+
[this.variant]: true,
|
|
133
|
+
[this.size]: true,
|
|
134
|
+
}
|
|
135
|
+
return html`
|
|
136
|
+
<button
|
|
137
|
+
class=${classMap(cssClasses)}
|
|
138
|
+
?disabled=${this.disabled}
|
|
139
|
+
type=${this.type}
|
|
140
|
+
>
|
|
141
|
+
${this.renderIconBefore()} ${this.label} ${this.renderIconAfter()}
|
|
142
|
+
${this.renderExpandingIcon()}
|
|
143
|
+
</button>
|
|
144
|
+
`
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function defineButtonElements() {
|
|
149
|
+
defineElement("button", LeuButton)
|
|
150
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
button {
|
|
6
|
+
font-family: var(--leu-font-black);
|
|
7
|
+
text-align: center;
|
|
8
|
+
appearance: none;
|
|
9
|
+
transition: background 0.1s ease;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
border: 1px solid transparent;
|
|
12
|
+
border-radius: 2px;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
column-gap: 8px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
button.round {
|
|
19
|
+
border-radius: 50%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
button:disabled {
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button:focus-visible {
|
|
27
|
+
border: 1px solid var(--leu-color-black-0);
|
|
28
|
+
outline: 2px solid var(--leu-color-func-cyan);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button.inverted:focus-visible {
|
|
32
|
+
border: 1px solid var(--leu-color-black-100);
|
|
33
|
+
outline: 2px solid var(--leu-color-black-0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([fluid]) button {
|
|
37
|
+
width: 100%;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* size - normal */
|
|
42
|
+
button.normal {
|
|
43
|
+
padding: 12px 24px;
|
|
44
|
+
font-size: 16px;
|
|
45
|
+
line-height: 24px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
button.normal.icon {
|
|
49
|
+
padding: 12px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* size - small */
|
|
53
|
+
button.small {
|
|
54
|
+
padding: 6px 24px;
|
|
55
|
+
font-size: 14px;
|
|
56
|
+
line-height: 20px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
button.small.icon {
|
|
60
|
+
padding: 8px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* primary */
|
|
64
|
+
button.primary {
|
|
65
|
+
color: var(--leu-color-black-0);
|
|
66
|
+
background: var(--leu-color-black-100);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
button.primary:hover {
|
|
70
|
+
color: var(--leu-color-black-0);
|
|
71
|
+
background: var(--leu-color-black-transp-80);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
button.primary.active {
|
|
75
|
+
color: var(--leu-color-black-0);
|
|
76
|
+
background: var(--leu-color-black-100);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
button.primary:disabled {
|
|
80
|
+
color: var(--leu-color-black-0);
|
|
81
|
+
background: var(--leu-color-black-transp-20);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* secondary */
|
|
85
|
+
button.secondary {
|
|
86
|
+
color: var(--leu-color-black-transp-60);
|
|
87
|
+
background: var(--leu-color-black-transp-10);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
button.secondary:hover {
|
|
91
|
+
color: var(--leu-color-black-100);
|
|
92
|
+
background: var(--leu-color-black-transp-20);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
button.secondary.active {
|
|
96
|
+
color: var(--leu-color-black-0);
|
|
97
|
+
background: var(--leu-color-black-100);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
button.secondary:disabled {
|
|
101
|
+
color: var(--leu-color-black-transp-20);
|
|
102
|
+
background: var(--leu-color-black-transp-5);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ghost */
|
|
106
|
+
button.ghost {
|
|
107
|
+
background: transparent;
|
|
108
|
+
padding: 0 0.5rem;
|
|
109
|
+
color: var(--leu-color-black-60);
|
|
110
|
+
font-family: var(--leu-font-regular);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
button.ghost:hover {
|
|
114
|
+
color: var(--leu-color-black-100);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
button.ghost.active {
|
|
118
|
+
color: var(--leu-color-black-100);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
button.ghost:disabled {
|
|
122
|
+
color: var(--leu-color-black-20);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* primary + inverted */
|
|
126
|
+
button.primary.inverted {
|
|
127
|
+
color: var(--leu-color-black-100);
|
|
128
|
+
background: var(--leu-color-black-0);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
button.primary.inverted:hover {
|
|
132
|
+
color: var(--leu-color-black-100);
|
|
133
|
+
background: var(--leu-color-white-transp-70);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
button.primary.inverted.active {
|
|
137
|
+
color: var(--leu-color-black-0);
|
|
138
|
+
background: var(--leu-color-black-100);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
button.primary.inverted:disabled {
|
|
142
|
+
color: var(--leu-color-black-40);
|
|
143
|
+
background: var(--leu-color-white-transp-70);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* secondary + inverted */
|
|
147
|
+
button.secondary.inverted {
|
|
148
|
+
color: var(--leu-color-black-0);
|
|
149
|
+
background: var(--leu-color-black-transp-20);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
button.secondary.inverted:hover {
|
|
153
|
+
color: var(--leu-color-black-0);
|
|
154
|
+
background: var(--leu-color-black-transp-40);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
button.secondary.inverted.active {
|
|
158
|
+
color: var(--leu-color-black-100);
|
|
159
|
+
background: var(--leu-color-black-0);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
button.secondary.inverted:disabled {
|
|
163
|
+
color: var(--leu-color-white-transp-70);
|
|
164
|
+
background: var(--leu-color-black-transp-10);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* ghost + inverted */
|
|
168
|
+
button.ghost.inverted {
|
|
169
|
+
color: var(--leu-color-black-0);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
button.ghost.inverted:hover {
|
|
173
|
+
color: var(--leu-color-white-transp-70);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
button.ghost.inverted.active {
|
|
177
|
+
color: var(--leu-color-black-0);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
button.ghost.inverted:disabled {
|
|
181
|
+
color: var(--leu-color-black-20);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* icon-wrapper */
|
|
185
|
+
.icon-wrapper svg {
|
|
186
|
+
display: block;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ghost :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
190
|
+
padding: 0.5rem;
|
|
191
|
+
border-radius: 50%;
|
|
192
|
+
background: var(--leu-color-black-transp-10);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.ghost.active :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
196
|
+
background: var(--leu-color-black-100);
|
|
197
|
+
color: var(--leu-color-black-0);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.ghost:disabled :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
201
|
+
background: var(--leu-color-black-transp-5);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* inverted */
|
|
205
|
+
|
|
206
|
+
.ghost.inverted :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
207
|
+
background: var(--leu-color-black-transp-20);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.ghost.inverted:hover :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
211
|
+
background: var(--leu-color-black-transp-40);
|
|
212
|
+
color: var(--leu-color-black-0);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.ghost.inverted:disabled :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
216
|
+
background: var(--leu-color-black-transp-20);
|
|
217
|
+
color: var(--leu-color-white-transp-70);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.ghost.active.inverted :is(.icon-wrapper--before, .icon-wrapper--after) {
|
|
221
|
+
background: var(--leu-color-black-0);
|
|
222
|
+
color: var(--leu-color-black-100);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Expanded icon */
|
|
226
|
+
.icon-wrapper--expanded {
|
|
227
|
+
transition: transform 0.1s ease;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
:host([expanded="open"]) .icon-wrapper--expanded {
|
|
231
|
+
transform: rotate(180deg);
|
|
232
|
+
}
|