@graupl/graupl 1.0.0-alpha.12 → 1.0.0-alpha.14
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/.github/workflows/codeql-analysis.yml +3 -3
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/CHANGELOG.md +65 -0
- package/dist/base/button.css +1 -1
- package/dist/base/button.css.map +1 -1
- package/dist/base/form.css +1 -1
- package/dist/base/form.css.map +1 -1
- package/dist/base/link.css +1 -1
- package/dist/base/link.css.map +1 -1
- package/dist/base/table.css +1 -1
- package/dist/base/table.css.map +1 -1
- package/dist/base.css +1 -1
- package/dist/base.css.map +1 -1
- package/dist/component/alert.css +2 -0
- package/dist/component/alert.css.map +1 -0
- package/dist/component/card.css +2 -0
- package/dist/component/card.css.map +1 -0
- package/dist/component/carousel.css +2 -0
- package/dist/component/carousel.css.map +1 -0
- package/dist/component/input-group.css +1 -1
- package/dist/component/input-group.css.map +1 -1
- package/dist/component/menu.css +2 -0
- package/dist/component/menu.css.map +1 -0
- package/dist/component/navigation.css +2 -0
- package/dist/component/navigation.css.map +1 -0
- package/dist/component.css +1 -1
- package/dist/component.css.map +1 -1
- package/dist/graupl.css +1 -1
- package/dist/graupl.css.map +1 -1
- package/dist/layout/columns.css +1 -1
- package/dist/layout/columns.css.map +1 -1
- package/dist/layout/container.css.map +1 -1
- package/dist/layout/flex-columns.css +2 -0
- package/dist/layout/flex-columns.css.map +1 -0
- package/dist/layout.css +1 -1
- package/dist/layout.css.map +1 -1
- package/dist/normalize.css.map +1 -1
- package/dist/state/focus.css.map +1 -1
- package/dist/state.css.map +1 -1
- package/dist/theme/color.css.map +1 -1
- package/dist/theme/typography.css +1 -1
- package/dist/theme/typography.css.map +1 -1
- package/dist/theme.css +1 -1
- package/dist/theme.css.map +1 -1
- package/dist/utilities/alignment.css.map +1 -1
- package/dist/utilities/color.css.map +1 -1
- package/dist/utilities/display.css +1 -1
- package/dist/utilities/display.css.map +1 -1
- package/dist/utilities/flex.css.map +1 -1
- package/dist/utilities/height.css +2 -0
- package/dist/utilities/height.css.map +1 -0
- package/dist/utilities/inset.css.map +1 -1
- package/dist/utilities/justification.css.map +1 -1
- package/dist/utilities/list.css.map +1 -1
- package/dist/utilities/order.css +2 -0
- package/dist/utilities/order.css.map +1 -0
- package/dist/utilities/postion.css.map +1 -1
- package/dist/utilities/spacing.css +1 -1
- package/dist/utilities/spacing.css.map +1 -1
- package/dist/utilities/typography.css +1 -1
- package/dist/utilities/typography.css.map +1 -1
- package/dist/utilities/visibility.css.map +1 -1
- package/dist/utilities/width.css +2 -0
- package/dist/utilities/width.css.map +1 -0
- package/dist/utilities.css +1 -1
- package/dist/utilities.css.map +1 -1
- package/docs/.vitepress/config.js +39 -12
- package/docs/components/alert.md +130 -0
- package/docs/components/button.md +84 -0
- package/docs/components/card.md +369 -0
- package/docs/components/index.md +1 -0
- package/docs/components/inputgroup.md +159 -0
- package/docs/components/menu.md +326 -0
- package/docs/components/navigation.md +158 -0
- package/docs/content.md +237 -0
- package/docs/defaults.md +121 -0
- package/docs/forms.md +79 -0
- package/docs/functions.md +9 -0
- package/docs/getting-started.md +1 -0
- package/docs/index.md +1 -7
- package/docs/introduction.md +22 -2
- package/docs/layout.md +200 -0
- package/docs/mixins.md +47 -0
- package/docs/state.md +67 -0
- package/docs/theme.md +258 -0
- package/docs/utilities.md +357 -0
- package/eslint.config.js +1 -0
- package/index.html +760 -325
- package/package.json +5 -6
- package/scss/component/alert.scss +3 -0
- package/scss/component/card.scss +3 -0
- package/scss/component/carousel.scss +3 -0
- package/scss/component/menu.scss +3 -0
- package/scss/component/navigation.scss +3 -0
- package/scss/layout/flex-columns.scss +3 -0
- package/scss/utilities/height.scss +3 -0
- package/scss/utilities/order.scss +3 -0
- package/scss/utilities/width.scss +3 -0
- package/src/js/alert/Alert.js +511 -0
- package/src/js/alert/index.js +21 -0
- package/src/js/carousel/Carousel.js +1376 -0
- package/src/js/carousel/index.js +20 -0
- package/src/js/domHelpers.js +37 -0
- package/src/js/eventHandlers.js +32 -0
- package/src/js/navigation.js +34 -0
- package/src/js/validate.js +225 -0
- package/src/scss/_defaults.scss +15 -1
- package/src/scss/base/_index.scss +1 -1
- package/src/scss/base/button/_defaults.scss +15 -3
- package/src/scss/base/button/_index.scss +80 -120
- package/src/scss/base/button/_mixins.scss +164 -0
- package/src/scss/base/button/_variables.scss +43 -11
- package/src/scss/base/form/_index.scss +3 -5
- package/src/scss/base/form/_variables.scss +8 -0
- package/src/scss/base/link/_defaults.scss +37 -6
- package/src/scss/base/link/_index.scss +73 -13
- package/src/scss/base/link/_variables.scss +175 -18
- package/src/scss/base/table/_index.scss +3 -5
- package/src/scss/base/table/_variables.scss +8 -0
- package/src/scss/component/_index.scss +6 -1
- package/src/scss/component/alert/_defaults.scss +49 -0
- package/src/scss/component/alert/_index.scss +118 -0
- package/src/scss/component/alert/_variables.scss +170 -0
- package/src/scss/component/card/_defaults.scss +32 -0
- package/src/scss/component/card/_index.scss +177 -0
- package/src/scss/component/card/_variables.scss +185 -0
- package/src/scss/component/carousel/_defaults.scss +43 -0
- package/src/scss/component/carousel/_index.scss +182 -0
- package/src/scss/component/carousel/_variables.scss +104 -0
- package/src/scss/component/input-group/_index.scss +1 -1
- package/src/scss/component/menu/_defaults.scss +66 -0
- package/src/scss/component/menu/_index.scss +305 -0
- package/src/scss/component/menu/_variables.scss +495 -0
- package/src/scss/component/navigation/_defaults.scss +29 -0
- package/src/scss/component/navigation/_index.scss +189 -0
- package/src/scss/component/navigation/_variables.scss +237 -0
- package/src/scss/functions/_theme.scss +16 -0
- package/src/scss/layout/_index.scss +2 -1
- package/src/scss/layout/columns/_index.scss +23 -1
- package/src/scss/layout/container/_index.scss +1 -1
- package/src/scss/layout/flex-columns/_defaults.scss +18 -0
- package/src/scss/layout/flex-columns/_index.scss +77 -0
- package/src/scss/layout/flex-columns/_variables.scss +26 -0
- package/src/scss/mixins/_layer.scss +2 -4
- package/src/scss/mixins/_media-queries.scss +8 -0
- package/src/scss/mixins/_visually-hidden.scss +20 -0
- package/src/scss/state/_index.scss +1 -1
- package/src/scss/state/focus/_index.scss +1 -1
- package/src/scss/theme/_index.scss +1 -1
- package/src/scss/theme/color/_index.scss +1 -1
- package/src/scss/theme/typography/_defaults.scss +1 -1
- package/src/scss/theme/typography/_index.scss +1 -1
- package/src/scss/theme/typography/_variables.scss +5 -2
- package/src/scss/utilities/_index.scss +5 -1
- package/src/scss/utilities/alignment/_index.scss +1 -1
- package/src/scss/utilities/color/_index.scss +1 -1
- package/src/scss/utilities/display/_defaults.scss +2 -0
- package/src/scss/utilities/display/_index.scss +11 -1
- package/src/scss/utilities/flex/_index.scss +1 -1
- package/src/scss/utilities/height/_defaults.scss +38 -0
- package/src/scss/utilities/height/_index.scss +23 -0
- package/src/scss/utilities/height/_variables.scss +6 -0
- package/src/scss/utilities/inset/_index.scss +1 -1
- package/src/scss/utilities/justification/_index.scss +1 -1
- package/src/scss/utilities/list/_index.scss +1 -1
- package/src/scss/utilities/order/_defaults.scss +19 -0
- package/src/scss/utilities/order/_index.scss +35 -0
- package/src/scss/utilities/order/_variables.scss +6 -0
- package/src/scss/utilities/position/_index.scss +1 -1
- package/src/scss/utilities/ratio/_defaults.scss +25 -0
- package/src/scss/utilities/ratio/_index.scss +34 -0
- package/src/scss/utilities/ratio/_variables.scss +9 -0
- package/src/scss/utilities/spacing/_index.scss +34 -17
- package/src/scss/utilities/typography/_index.scss +1 -1
- package/src/scss/utilities/visibility/_index.scss +1 -1
- package/src/scss/utilities/width/_defaults.scss +38 -0
- package/src/scss/utilities/width/_index.scss +23 -0
- package/src/scss/utilities/width/_variables.scss +6 -0
- package/stylelint.config.js +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Carousel from "./Carousel.js";
|
|
2
|
+
|
|
3
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
4
|
+
const carousels = [];
|
|
5
|
+
|
|
6
|
+
document.querySelectorAll(".carousel").forEach((carouselElement) => {
|
|
7
|
+
const carousel = new Carousel({
|
|
8
|
+
carouselElement,
|
|
9
|
+
initialize: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
carousels.push(carousel);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const graupl = window.Graupl || {};
|
|
16
|
+
|
|
17
|
+
graupl.carousels = carousels;
|
|
18
|
+
|
|
19
|
+
window.Graupl = graupl;
|
|
20
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add a class or array of classes to an element.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|string[]} className - The class or classes to add.
|
|
5
|
+
* @param {HTMLElement} element - The element to add the class to.
|
|
6
|
+
*/
|
|
7
|
+
export function addClass(className, element) {
|
|
8
|
+
// Gracefully handle empty strings or arrays.
|
|
9
|
+
if (className === "" || className.length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof className === "string") {
|
|
14
|
+
element.classList.add(className);
|
|
15
|
+
} else {
|
|
16
|
+
element.classList.add(...className);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Remove a class or array of classes from an element.
|
|
22
|
+
*
|
|
23
|
+
* @param {string|string[]} className - The class or classes to remove.
|
|
24
|
+
* @param {HTMLElement} element - The element to remove the class from.
|
|
25
|
+
*/
|
|
26
|
+
export function removeClass(className, element) {
|
|
27
|
+
// Gracefully handle empty strings or arrays.
|
|
28
|
+
if (className === "" || className.length === 0) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof className === "string") {
|
|
33
|
+
element.classList.remove(className);
|
|
34
|
+
} else {
|
|
35
|
+
element.classList.remove(...className);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the pressed key from an event.
|
|
3
|
+
*
|
|
4
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
5
|
+
* @return {string} - The name of the key or an empty string.
|
|
6
|
+
*/
|
|
7
|
+
export function keyPress(event) {
|
|
8
|
+
try {
|
|
9
|
+
// Use event.key or event.keyCode to support older browsers.
|
|
10
|
+
const key = event.key || event.keyCode;
|
|
11
|
+
const keys = {
|
|
12
|
+
Enter: key === "Enter" || key === 13,
|
|
13
|
+
Space: key === " " || key === "Spacebar" || key === 32,
|
|
14
|
+
Escape: key === "Escape" || key === "Esc" || key === 27,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return Object.keys(keys).find((key) => keys[key] === true) || "";
|
|
18
|
+
} catch {
|
|
19
|
+
// Return an empty string if something goes wrong.
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Stops an event from taking action.
|
|
26
|
+
*
|
|
27
|
+
* @param {Event} event - The event.
|
|
28
|
+
*/
|
|
29
|
+
export function preventEvent(event) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
2
|
+
const navs = document.querySelectorAll(".navigation");
|
|
3
|
+
const menus = [];
|
|
4
|
+
|
|
5
|
+
navs.forEach((nav) => {
|
|
6
|
+
const MenuConstructor = nav.dataset.grauplMenuType || DisclosureMenu;
|
|
7
|
+
|
|
8
|
+
if (window[MenuConstructor] === undefined) {
|
|
9
|
+
console.warn(
|
|
10
|
+
`Graupl navigation requires accessible-menu's ${MenuConstructor}. Please make sure to include it on this page.`
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const menuOptions =
|
|
17
|
+
JSON.parse(nav.dataset.grauplMenuOptions.replace(/'/g, '"')) || {};
|
|
18
|
+
const menuElement = nav.querySelector(".menu");
|
|
19
|
+
const controllerElement = nav.querySelector(".navigation-toggle");
|
|
20
|
+
const containerElement = nav;
|
|
21
|
+
const menu = new window[MenuConstructor]({
|
|
22
|
+
menuElement,
|
|
23
|
+
menuItemSelector: ".menu-item",
|
|
24
|
+
menuLinkSelector: ".menu-link",
|
|
25
|
+
submenuItemSelector: ".submenu-item",
|
|
26
|
+
submenuToggleSelector: ".submenu-toggle",
|
|
27
|
+
controllerElement,
|
|
28
|
+
containerElement,
|
|
29
|
+
...menuOptions,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
menus.push(menu);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check to see if the provided elements have a specific contructor.
|
|
3
|
+
*
|
|
4
|
+
* The values must be provided inside of an object
|
|
5
|
+
* so the variable name can be retrieved in case of errors.
|
|
6
|
+
*
|
|
7
|
+
* This is essentially just a wrapper function around checking instanceof with
|
|
8
|
+
* more descriptive error message to help debugging.
|
|
9
|
+
*
|
|
10
|
+
* Will return `{ status: true }` if the check is successful.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} contructor - The constructor to check for.
|
|
13
|
+
* @param {object} elements - The element(s) to check.
|
|
14
|
+
* @return {Object<boolean, string>} - The result of the check.
|
|
15
|
+
*/
|
|
16
|
+
export function isValidInstance(contructor, elements) {
|
|
17
|
+
try {
|
|
18
|
+
if (typeof elements !== "object") {
|
|
19
|
+
const elementsType = typeof elements;
|
|
20
|
+
|
|
21
|
+
throw new TypeError(
|
|
22
|
+
`Elements given to isValidInstance() must be inside of an object. "${elementsType}" given.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const key in elements) {
|
|
27
|
+
if (!(elements[key] instanceof contructor)) {
|
|
28
|
+
const elementType = typeof elements[key];
|
|
29
|
+
throw new TypeError(
|
|
30
|
+
`${key} must be an instance of ${contructor.name}. "${elementType}" given.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
status: true,
|
|
37
|
+
error: null,
|
|
38
|
+
};
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return {
|
|
41
|
+
status: false,
|
|
42
|
+
error,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check to see if the provided values are of a specific type.
|
|
49
|
+
*
|
|
50
|
+
* The values must be provided inside of an object
|
|
51
|
+
* so the variable name can be retrieved in case of errors.
|
|
52
|
+
*
|
|
53
|
+
* This is essentially just a wrapper function around checking typeof with
|
|
54
|
+
* more descriptive error message to help debugging.
|
|
55
|
+
*
|
|
56
|
+
* Will return `{ status: true }` if the check is successful.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} type - The type to check for.
|
|
59
|
+
* @param {object} values - The value(s) to check.
|
|
60
|
+
* @return {Object<boolean, string>} - The result of the check.
|
|
61
|
+
*/
|
|
62
|
+
export function isValidType(type, values) {
|
|
63
|
+
try {
|
|
64
|
+
if (typeof values !== "object") {
|
|
65
|
+
const valuesType = typeof values;
|
|
66
|
+
|
|
67
|
+
throw new TypeError(
|
|
68
|
+
`Values given to isValidType() must be inside of an object. "${valuesType}" given.`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const key in values) {
|
|
73
|
+
const valueType = typeof values[key];
|
|
74
|
+
|
|
75
|
+
if (valueType !== type) {
|
|
76
|
+
throw new TypeError(`${key} must be a ${type}. "${valueType}" given.`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
status: true,
|
|
82
|
+
error: null,
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
status: false,
|
|
87
|
+
error,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Checks to see if the provided values are valid query selectors.
|
|
94
|
+
*
|
|
95
|
+
* The values must be provided inside of an object
|
|
96
|
+
* so the variable name can be retrieved in case of errors.
|
|
97
|
+
*
|
|
98
|
+
* Will return `{ status: true }` if the check is successful.
|
|
99
|
+
*
|
|
100
|
+
* @param {Object<string>} values - The value(s) to check.
|
|
101
|
+
* @return {Object<boolean, string>} - The result of the check.
|
|
102
|
+
*/
|
|
103
|
+
export function isQuerySelector(values) {
|
|
104
|
+
try {
|
|
105
|
+
if (typeof values !== "object") {
|
|
106
|
+
const type = typeof values;
|
|
107
|
+
|
|
108
|
+
throw new TypeError(
|
|
109
|
+
`Values given to isQuerySelector() must be inside of an object. "${type}" given.`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const key in values) {
|
|
114
|
+
try {
|
|
115
|
+
if (values[key] === null) {
|
|
116
|
+
throw new Error();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
document.querySelector(values[key]);
|
|
120
|
+
} catch {
|
|
121
|
+
throw new TypeError(
|
|
122
|
+
`${key} must be a valid query selector. "${values[key]}" given.`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
status: true,
|
|
129
|
+
error: null,
|
|
130
|
+
};
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return {
|
|
133
|
+
status: false,
|
|
134
|
+
error,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Checks to see if the provided value is either a string or an array of strings.
|
|
141
|
+
*
|
|
142
|
+
* The values must be provided inside of an object
|
|
143
|
+
* so the variable name can be retrieved in case of errors.
|
|
144
|
+
*
|
|
145
|
+
* Will return `{ status: true }` if the check is successful.
|
|
146
|
+
*
|
|
147
|
+
* @param {Object<string, string[]>} values - The value(s) to check.
|
|
148
|
+
* @return {Object<boolean, string>} - The result of the check.
|
|
149
|
+
*/
|
|
150
|
+
export function isValidClassList(values) {
|
|
151
|
+
try {
|
|
152
|
+
if (typeof values !== "object" || Array.isArray(values)) {
|
|
153
|
+
const type = typeof values;
|
|
154
|
+
|
|
155
|
+
throw new TypeError(
|
|
156
|
+
`Values given to isValidClassList() must be inside of an object. "${type}" given.`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
for (const key in values) {
|
|
161
|
+
const type = typeof values[key];
|
|
162
|
+
|
|
163
|
+
if (type !== "string") {
|
|
164
|
+
if (Array.isArray(values[key])) {
|
|
165
|
+
values[key].forEach((value) => {
|
|
166
|
+
if (typeof value !== "string") {
|
|
167
|
+
throw new TypeError(
|
|
168
|
+
`${key} must be a string or an array of strings. An array containing non-strings given.`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
throw new TypeError(
|
|
174
|
+
`${key} must be a string or an array of strings. "${type}" given.`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
const obj = {};
|
|
179
|
+
obj[key] = values[key];
|
|
180
|
+
|
|
181
|
+
isQuerySelector(obj);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
status: true,
|
|
187
|
+
error: null,
|
|
188
|
+
};
|
|
189
|
+
} catch (error) {
|
|
190
|
+
return {
|
|
191
|
+
status: false,
|
|
192
|
+
error,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Checks to see if the provided elements are using a specific tag.
|
|
199
|
+
*
|
|
200
|
+
* The elements must be provided inside of an object
|
|
201
|
+
* so the variable name can be retrieved in case of errors.
|
|
202
|
+
*
|
|
203
|
+
* Will return `true` if the check is successful.
|
|
204
|
+
*
|
|
205
|
+
* @param {string} tagName - The name of the tag.
|
|
206
|
+
* @param {Object<HTMLElement>} elements - The element(s) to check.
|
|
207
|
+
* @return {boolean} - The result of the check.
|
|
208
|
+
*/
|
|
209
|
+
export function isTag(tagName, elements) {
|
|
210
|
+
if (
|
|
211
|
+
isValidType("string", { tagName }).status &&
|
|
212
|
+
isValidInstance(HTMLElement, elements).status
|
|
213
|
+
) {
|
|
214
|
+
const tag = tagName.toLowerCase();
|
|
215
|
+
let check = true;
|
|
216
|
+
|
|
217
|
+
for (const key in elements) {
|
|
218
|
+
if (elements[key].tagName.toLowerCase() !== tag) check = false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return check;
|
|
222
|
+
} else {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
package/src/scss/_defaults.scss
CHANGED
|
@@ -19,10 +19,24 @@ $content-max-width: 96ch !default;
|
|
|
19
19
|
|
|
20
20
|
// Screen sizes.
|
|
21
21
|
$base-screen-sizes: (
|
|
22
|
-
xs: "(
|
|
22
|
+
xs: "(width <= 48ch)",
|
|
23
|
+
sm: "(48ch < width)",
|
|
24
|
+
md: "(72ch < width)",
|
|
25
|
+
lg: "(108ch < width)",
|
|
26
|
+
xl: "(156ch < width)",
|
|
23
27
|
);
|
|
24
28
|
$custom-screen-sizes: () !default;
|
|
25
29
|
$screen-sizes: map.merge($base-screen-sizes, $custom-screen-sizes);
|
|
30
|
+
$base-screen-size-triggers: (
|
|
31
|
+
navigation-collapse: "(width <= 72ch)",
|
|
32
|
+
navigation-expand: "(72ch < width)",
|
|
33
|
+
force-vertical-card: "(width <= 72ch)",
|
|
34
|
+
);
|
|
35
|
+
$custom-screen-size-triggers: () !default;
|
|
36
|
+
$screen-size-triggers: map.merge(
|
|
37
|
+
$base-screen-size-triggers,
|
|
38
|
+
$custom-screen-size-triggers
|
|
39
|
+
);
|
|
26
40
|
|
|
27
41
|
// Spacing properties.
|
|
28
42
|
$spacer: 1rem !default;
|
|
@@ -13,12 +13,20 @@ $button-selector: ".button" !default;
|
|
|
13
13
|
$button-link-selector: ".link" !default;
|
|
14
14
|
$button-theme-selector-prefix: "." !default;
|
|
15
15
|
|
|
16
|
+
// State selectors.
|
|
17
|
+
$button-active-selector: ".active" !default;
|
|
18
|
+
$button-disabled-selector: ".disabled" !default;
|
|
19
|
+
$button-focus-selector: ".focus" !default;
|
|
20
|
+
$button-hover-selector: ".hover" !default;
|
|
21
|
+
$button-visited-selector: ".visited" !default;
|
|
22
|
+
|
|
16
23
|
// Button properties.
|
|
17
24
|
$button-transform: none !default;
|
|
18
|
-
$button-
|
|
19
|
-
$button-
|
|
25
|
+
$button-visited-transform: $button-transform !default;
|
|
26
|
+
$button-focus-transform: $button-transform !default;
|
|
27
|
+
$button-hover-transform: $button-transform !default;
|
|
20
28
|
$button-active-transform: scale(0.95) !default;
|
|
21
|
-
$button-
|
|
29
|
+
$button-disabled-transform: $button-transform !default;
|
|
22
30
|
|
|
23
31
|
// Button state theme defaults.
|
|
24
32
|
// This map is used to define the default colour shades for the
|
|
@@ -32,6 +40,10 @@ $button-active-transform-reduced-motion: scale(0.98) !default;
|
|
|
32
40
|
$base-button-state-theme-map: (
|
|
33
41
|
color: 900,
|
|
34
42
|
border-color: 700,
|
|
43
|
+
visited-color: 900,
|
|
44
|
+
visited-border-color: 700,
|
|
45
|
+
focus-color: 900,
|
|
46
|
+
focus-border-color: 700,
|
|
35
47
|
hover-color: 100,
|
|
36
48
|
hover-background: 700,
|
|
37
49
|
hover-border-color: 700,
|
|
@@ -1,147 +1,107 @@
|
|
|
1
|
-
// @
|
|
1
|
+
// @graupl/graupl button base styles.
|
|
2
2
|
|
|
3
3
|
@use "defaults";
|
|
4
4
|
@use "../../defaults" as root-defaults;
|
|
5
|
-
@use "
|
|
5
|
+
@use "../link/defaults" as link-defaults;
|
|
6
6
|
@use "../../base/link/variables" as link;
|
|
7
7
|
@use "variables" as *;
|
|
8
|
+
@use "mixins" as *;
|
|
8
9
|
@use "../../mixins/layer" as *;
|
|
9
|
-
@use "../../mixins/media-queries" as *;
|
|
10
|
-
@use "sass:map";
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
transform:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
border-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
#{defaults.$button-selector} {
|
|
12
|
+
@include apply-button;
|
|
13
|
+
|
|
14
|
+
&#{defaults.$button-link-selector} {
|
|
15
|
+
--#{root-defaults.$prefix}-button-padding: #{link.$link-padding};
|
|
16
|
+
--#{root-defaults.$prefix}-button-transition: #{link.$link-transition};
|
|
17
|
+
--#{root-defaults.$prefix}-button-transition-reduced-motion: #{link.$link-transition-reduced-motion};
|
|
18
|
+
--#{root-defaults.$prefix}-button-transform: #{link.$link-transform};
|
|
19
|
+
--#{root-defaults.$prefix}-button-visited-transform: #{link.$link-visited-transform};
|
|
20
|
+
--#{root-defaults.$prefix}-button-focus-transform: #{link.$link-transform};
|
|
21
|
+
--#{root-defaults.$prefix}-button-hover-transform: #{link.$link-hover-transform};
|
|
22
|
+
--#{root-defaults.$prefix}-button-active-transform: #{link.$link-active-transform};
|
|
23
|
+
--#{root-defaults.$prefix}-button-border-width: #{link.$link-border-width};
|
|
24
|
+
--#{root-defaults.$prefix}-button-border-style: #{link.$link-border-style};
|
|
25
|
+
--#{root-defaults.$prefix}-button-border-radius: #{link.$link-border-radius};
|
|
26
|
+
--#{root-defaults.$prefix}-button-min-width: #{link.$link-min-width};
|
|
27
|
+
--#{root-defaults.$prefix}-button-min-height: #{link.$link-min-height};
|
|
28
|
+
--#{root-defaults.$prefix}-button-font-size: inherit;
|
|
29
|
+
|
|
30
|
+
text-decoration: link.$link-text-decoration;
|
|
31
|
+
text-decoration-thickness: link.$link-text-decoration-thickness;
|
|
32
|
+
text-decoration-style: link.$link-text-decoration-style;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
36
|
+
@include layer(base) {
|
|
37
|
+
#{defaults.$button-selector}#{defaults.$button-link-selector} {
|
|
38
|
+
--#{root-defaults.$prefix}-button-color: #{link.$link-color};
|
|
39
|
+
--#{root-defaults.$prefix}-button-visited-color: #{link.$link-visited-color};
|
|
40
|
+
--#{root-defaults.$prefix}-button-focus-color: #{link.$link-focus-color};
|
|
41
|
+
--#{root-defaults.$prefix}-button-hover-color: #{link.$link-hover-color};
|
|
42
|
+
--#{root-defaults.$prefix}-button-active-color: #{link.$link-active-color};
|
|
43
|
+
--#{root-defaults.$prefix}-button-disabled-color: #{link.$link-disabled-color};
|
|
44
|
+
--#{root-defaults.$prefix}-button-background: #{link.$link-background};
|
|
45
|
+
--#{root-defaults.$prefix}-button-visited-background: #{link.$link-visited-background};
|
|
46
|
+
--#{root-defaults.$prefix}-button-focus-background: #{link.$link-focus-background};
|
|
47
|
+
--#{root-defaults.$prefix}-button-hover-background: #{link.$link-hover-background};
|
|
48
|
+
--#{root-defaults.$prefix}-button-active-background: #{link.$link-active-background};
|
|
49
|
+
--#{root-defaults.$prefix}-button-disabled-background: #{link.$link-disabled-background};
|
|
50
|
+
--#{root-defaults.$prefix}-button-border-color: #{link.$link-border-color};
|
|
51
|
+
--#{root-defaults.$prefix}-button-visited-border-color: #{link.$link-visited-border-color};
|
|
52
|
+
--#{root-defaults.$prefix}-button-focus-border-color: #{link.$link-focus-border-color};
|
|
53
|
+
--#{root-defaults.$prefix}-button-hover-border-color: #{link.$link-hover-border-color};
|
|
54
|
+
--#{root-defaults.$prefix}-button-active-border-color: #{link.$link-active-border-color};
|
|
55
|
+
--#{root-defaults.$prefix}-button-disabled-border-color: #{link.$link-disabled-border-color};
|
|
56
|
+
}
|
|
35
57
|
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
#{link-defaults.$link-selector} {
|
|
59
|
+
&#{defaults.$button-selector}:not(#{defaults.$button-link-selector}) {
|
|
38
60
|
--#{root-defaults.$prefix}-link-padding: #{$button-padding};
|
|
39
61
|
--#{root-defaults.$prefix}-link-transition: #{$button-transition};
|
|
40
62
|
--#{root-defaults.$prefix}-link-transition-reduced-motion: #{$button-transition-reduced-motion};
|
|
41
63
|
--#{root-defaults.$prefix}-link-transform: #{$button-transform};
|
|
64
|
+
--#{root-defaults.$prefix}-link-visited-transform: #{$button-visited-transform};
|
|
65
|
+
--#{root-defaults.$prefix}-link-focus-transform: #{$button-focus-transform};
|
|
42
66
|
--#{root-defaults.$prefix}-link-hover-transform: #{$button-hover-transform};
|
|
43
67
|
--#{root-defaults.$prefix}-link-active-transform: #{$button-active-transform};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
&#{defaults.$button-link-selector} {
|
|
57
|
-
--#{root-defaults.$prefix}-button-padding: #{link.$link-padding};
|
|
58
|
-
--#{root-defaults.$prefix}-button-transition: #{link.$link-transition};
|
|
59
|
-
--#{root-defaults.$prefix}-button-transition-reduced-motion: #{link.$link-transition-reduced-motion};
|
|
60
|
-
--#{root-defaults.$prefix}-button-transform: #{link.$link-transform};
|
|
61
|
-
--#{root-defaults.$prefix}-button-hover-transform: #{link.$link-hover-transform};
|
|
62
|
-
--#{root-defaults.$prefix}-button-active-transform: #{link.$link-active-transform};
|
|
63
|
-
|
|
64
|
-
min-width: auto;
|
|
65
|
-
min-height: auto;
|
|
66
|
-
border: 0;
|
|
67
|
-
font-size: inherit;
|
|
68
|
-
text-decoration: link.$link-text-decoration;
|
|
69
|
-
text-decoration-thickness: link.$link-text-decoration-thickness;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@include animation-off {
|
|
74
|
-
#{defaults.$button-selector} {
|
|
75
|
-
--#{root-defaults.$prefix}-button-transition: #{$button-transition-reduced-motion};
|
|
76
|
-
--#{root-defaults.$prefix}-button-hover-transform: #{$button-hover-transform-reduced-motion};
|
|
77
|
-
--#{root-defaults.$prefix}-button-active-transform: #{$button-active-transform-reduced-motion};
|
|
68
|
+
--#{root-defaults.$prefix}-link-disabled-transform: #{$button-disabled-transform};
|
|
69
|
+
--#{root-defaults.$prefix}-link-border-width: #{$button-border-width};
|
|
70
|
+
--#{root-defaults.$prefix}-link-border-style: #{$button-border-style};
|
|
71
|
+
--#{root-defaults.$prefix}-link-border-radius: #{$button-border-radius};
|
|
72
|
+
--#{root-defaults.$prefix}-link-min-width: #{$button-min-width};
|
|
73
|
+
--#{root-defaults.$prefix}-link-min-height: #{$button-min-height};
|
|
74
|
+
--#{root-defaults.$prefix}-link-text-decoration: none;
|
|
75
|
+
--#{root-defaults.$prefix}-link-visited-text-decoration: none;
|
|
76
|
+
--#{root-defaults.$prefix}-link-focus-text-decoration: none;
|
|
77
|
+
--#{root-defaults.$prefix}-link-hover-text-decoration: none;
|
|
78
|
+
--#{root-defaults.$prefix}-link-active-text-decoration: none;
|
|
79
|
+
--#{root-defaults.$prefix}-link-disabled-text-decoration: none;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
@include layer(theme) {
|
|
83
|
-
#{defaults.$
|
|
84
|
-
|
|
85
|
-
background: $button-background;
|
|
86
|
-
color: $button-color;
|
|
87
|
-
|
|
88
|
-
@each $color, $map in color.$theme-active {
|
|
89
|
-
&#{defaults.$button-theme-selector-prefix}#{$color} {
|
|
90
|
-
@each $prop, $shade in defaults.$button-state-theme-map {
|
|
91
|
-
--#{root-defaults.$prefix}-button-#{$prop}: #{map.get($map, $shade)};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
&#{defaults.$button-link-selector} {
|
|
97
|
-
--#{root-defaults.$prefix}-button-color: #{link.$link-color};
|
|
98
|
-
--#{root-defaults.$prefix}-button-hover-color: #{link.$link-hover-color};
|
|
99
|
-
--#{root-defaults.$prefix}-button-active-color: #{link.$link-active-color};
|
|
100
|
-
--#{root-defaults.$prefix}-button-disabled-color: #{link.$link-disabled-color};
|
|
101
|
-
--#{root-defaults.$prefix}-button-background: #{link.$link-background};
|
|
102
|
-
--#{root-defaults.$prefix}-button-hover-background: #{link.$link-hover-background};
|
|
103
|
-
--#{root-defaults.$prefix}-button-active-background: #{link.$link-active-background};
|
|
104
|
-
--#{root-defaults.$prefix}-button-disabled-background: #{link.$link-disabled-background};
|
|
105
|
-
--#{root-defaults.$prefix}-button-border-color: none;
|
|
106
|
-
--#{root-defaults.$prefix}-button-hover-border-color: none;
|
|
107
|
-
--#{root-defaults.$prefix}-button-active-border-color: none;
|
|
108
|
-
--#{root-defaults.$prefix}-button-disabled-border-color: none;
|
|
109
|
-
--#{root-defaults.$prefix}-button-hover-transform: none;
|
|
110
|
-
--#{root-defaults.$prefix}-button-active-transform: none;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
&:not(#{defaults.$button-link-selector}) {
|
|
85
|
+
#{link-defaults.$link-selector} {
|
|
86
|
+
&#{defaults.$button-selector}:not(#{defaults.$button-link-selector}) {
|
|
114
87
|
--#{root-defaults.$prefix}-link-color: #{$button-color};
|
|
88
|
+
--#{root-defaults.$prefix}-link-visited-color: #{$button-visited-color};
|
|
89
|
+
--#{root-defaults.$prefix}-link-focus-color: #{$button-focus-color};
|
|
115
90
|
--#{root-defaults.$prefix}-link-hover-color: #{$button-hover-color};
|
|
116
91
|
--#{root-defaults.$prefix}-link-active-color: #{$button-active-color};
|
|
117
|
-
--#{root-defaults.$prefix}-link-visited-color: #{$button-hover-color};
|
|
118
92
|
--#{root-defaults.$prefix}-link-disabled-color: #{$button-disabled-color};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
--#{root-defaults.$prefix}-
|
|
123
|
-
--#{root-defaults.$prefix}-
|
|
124
|
-
--#{root-defaults.$prefix}-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
--#{root-defaults.$prefix}-
|
|
129
|
-
--#{root-defaults.$prefix}-
|
|
130
|
-
--#{root-defaults.$prefix}-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
&:disabled,
|
|
134
|
-
&[disabled] {
|
|
135
|
-
--#{root-defaults.$prefix}-button-border-color: #{$button-disabled-border-color};
|
|
136
|
-
--#{root-defaults.$prefix}-button-background: #{$button-disabled-background};
|
|
137
|
-
--#{root-defaults.$prefix}-button-color: #{$button-disabled-color};
|
|
138
|
-
|
|
139
|
-
&:hover,
|
|
140
|
-
&:active {
|
|
141
|
-
--#{root-defaults.$prefix}-button-border-color: #{$button-disabled-border-color};
|
|
142
|
-
--#{root-defaults.$prefix}-button-background: #{$button-disabled-background};
|
|
143
|
-
--#{root-defaults.$prefix}-button-color: #{$button-disabled-color};
|
|
144
|
-
}
|
|
93
|
+
--#{root-defaults.$prefix}-link-background: #{$button-background};
|
|
94
|
+
--#{root-defaults.$prefix}-link-visited-background: #{$button-visited-background};
|
|
95
|
+
--#{root-defaults.$prefix}-link-focus-background: #{$button-focus-background};
|
|
96
|
+
--#{root-defaults.$prefix}-link-hover-background: #{$button-hover-background};
|
|
97
|
+
--#{root-defaults.$prefix}-link-active-background: #{$button-active-background};
|
|
98
|
+
--#{root-defaults.$prefix}-link-disabled-background: #{$button-disabled-background};
|
|
99
|
+
--#{root-defaults.$prefix}-link-border-color: #{$button-border-color};
|
|
100
|
+
--#{root-defaults.$prefix}-link-visited-border-color: #{$button-visited-border-color};
|
|
101
|
+
--#{root-defaults.$prefix}-link-focus-border-color: #{$button-focus-border-color};
|
|
102
|
+
--#{root-defaults.$prefix}-link-hover-border-color: #{$button-hover-border-color};
|
|
103
|
+
--#{root-defaults.$prefix}-link-active-border-color: #{$button-active-border-color};
|
|
104
|
+
--#{root-defaults.$prefix}-link-disabled-border-color: #{$button-disabled-border-color};
|
|
145
105
|
}
|
|
146
106
|
}
|
|
147
107
|
}
|