@inglorious/ui 0.1.0

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.
Files changed (83) hide show
  1. package/LICENSE +9 -0
  2. package/package.json +142 -0
  3. package/src/controls/button/button.stories.js +139 -0
  4. package/src/controls/button/index.js +5 -0
  5. package/src/controls/button/style.css +148 -0
  6. package/src/controls/button/template.js +74 -0
  7. package/src/controls/button-group/button-group.stories.js +108 -0
  8. package/src/controls/button-group/index.js +4 -0
  9. package/src/controls/button-group/style.css +58 -0
  10. package/src/controls/button-group/template.js +117 -0
  11. package/src/controls/checkbox/checkbox.stories.js +47 -0
  12. package/src/controls/checkbox/index.js +4 -0
  13. package/src/controls/checkbox/style.css +33 -0
  14. package/src/controls/checkbox/template.js +54 -0
  15. package/src/controls/fab/fab.stories.js +52 -0
  16. package/src/controls/fab/index.js +4 -0
  17. package/src/controls/fab/style.css +76 -0
  18. package/src/controls/fab/template.js +33 -0
  19. package/src/controls/icon-button/icon-button.stories.js +70 -0
  20. package/src/controls/icon-button/index.js +4 -0
  21. package/src/controls/icon-button/style.css +14 -0
  22. package/src/controls/icon-button/template.js +47 -0
  23. package/src/controls/input/index.js +4 -0
  24. package/src/controls/input/input.stories.js +180 -0
  25. package/src/controls/input/style.css +121 -0
  26. package/src/controls/input/template.js +111 -0
  27. package/src/controls/radio-group/index.js +4 -0
  28. package/src/controls/radio-group/radio-group.stories.js +51 -0
  29. package/src/controls/radio-group/style.css +41 -0
  30. package/src/controls/radio-group/template.js +71 -0
  31. package/src/controls/rating/index.js +4 -0
  32. package/src/controls/rating/rating.stories.js +47 -0
  33. package/src/controls/rating/style.css +29 -0
  34. package/src/controls/rating/template.js +53 -0
  35. package/src/controls/select/handlers.js +133 -0
  36. package/src/controls/select/helpers.js +91 -0
  37. package/src/controls/select/index.js +15 -0
  38. package/src/controls/select/select.stories.js +90 -0
  39. package/src/controls/select/style.css +211 -0
  40. package/src/controls/select/template.js +423 -0
  41. package/src/controls/slider/index.js +4 -0
  42. package/src/controls/slider/slider.stories.js +43 -0
  43. package/src/controls/slider/style.css +28 -0
  44. package/src/controls/slider/template.js +66 -0
  45. package/src/controls/switch/index.js +4 -0
  46. package/src/controls/switch/style.css +82 -0
  47. package/src/controls/switch/switch.stories.js +45 -0
  48. package/src/controls/switch/template.js +55 -0
  49. package/src/index.js +14 -0
  50. package/src/layout/flex/flex.stories.js +103 -0
  51. package/src/layout/flex/index.js +4 -0
  52. package/src/layout/flex/style.css +103 -0
  53. package/src/layout/flex/template.js +41 -0
  54. package/src/layout/grid/grid.stories.js +82 -0
  55. package/src/layout/grid/index.js +4 -0
  56. package/src/layout/grid/style.css +51 -0
  57. package/src/layout/grid/template.js +47 -0
  58. package/src/shared/applyElementProps.js +79 -0
  59. package/src/shared/withRenderValidation.js +19 -0
  60. package/src/stories/notifyStory.js +43 -0
  61. package/src/themes/bootstrap.css +118 -0
  62. package/src/themes/inglorious.css +106 -0
  63. package/src/themes/material.css +124 -0
  64. package/src/tokens/index.css +133 -0
  65. package/src/widgets/card/card.stories.js +135 -0
  66. package/src/widgets/card/index.js +4 -0
  67. package/src/widgets/card/style.css +53 -0
  68. package/src/widgets/card/template.js +97 -0
  69. package/types/controls/button-group.d.ts +35 -0
  70. package/types/controls/button.d.ts +23 -0
  71. package/types/controls/checkbox.d.ts +18 -0
  72. package/types/controls/fab.d.ts +19 -0
  73. package/types/controls/icon-button.d.ts +23 -0
  74. package/types/controls/input.d.ts +29 -0
  75. package/types/controls/radio-group.d.ts +25 -0
  76. package/types/controls/rating.d.ts +18 -0
  77. package/types/controls/select.d.ts +56 -0
  78. package/types/controls/slider.d.ts +21 -0
  79. package/types/controls/switch.d.ts +17 -0
  80. package/types/index.d.ts +14 -0
  81. package/types/layout/flex.d.ts +20 -0
  82. package/types/layout/grid.d.ts +19 -0
  83. package/types/widgets/card.d.ts +21 -0
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2025 Inglorious Coderz Srl.
4
+
5
+ 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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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.
package/package.json ADDED
@@ -0,0 +1,142 @@
1
+ {
2
+ "name": "@inglorious/ui",
3
+ "version": "0.1.0",
4
+ "description": "A design system for Inglorious Web with render-function components and customizable themes",
5
+ "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/IngloriousCoderz/inglorious-forge.git",
10
+ "directory": "packages/ui"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/IngloriousCoderz/inglorious-forge/issues"
14
+ },
15
+ "keywords": [
16
+ "design-system",
17
+ "ui",
18
+ "components",
19
+ "lit-html",
20
+ "inglorious-web",
21
+ "theme"
22
+ ],
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./types/index.d.ts",
27
+ "import": "./src/index.js"
28
+ },
29
+ "./tokens": "./src/tokens/index.css",
30
+ "./themes/inglorious": "./src/themes/inglorious.css",
31
+ "./themes/material": "./src/themes/material.css",
32
+ "./themes/bootstrap": "./src/themes/bootstrap.css",
33
+ "./button": {
34
+ "types": "./types/controls/button.d.ts",
35
+ "import": "./src/controls/button/index.js"
36
+ },
37
+ "./button.css": "./src/controls/button/style.css",
38
+ "./button-group": {
39
+ "types": "./types/controls/button-group.d.ts",
40
+ "import": "./src/controls/button-group/index.js"
41
+ },
42
+ "./button-group.css": "./src/controls/button-group/style.css",
43
+ "./checkbox": {
44
+ "types": "./types/controls/checkbox.d.ts",
45
+ "import": "./src/controls/checkbox/index.js"
46
+ },
47
+ "./checkbox.css": "./src/controls/checkbox/style.css",
48
+ "./fab": {
49
+ "types": "./types/controls/fab.d.ts",
50
+ "import": "./src/controls/fab/index.js"
51
+ },
52
+ "./fab.css": "./src/controls/fab/style.css",
53
+ "./icon-button": {
54
+ "types": "./types/controls/icon-button.d.ts",
55
+ "import": "./src/controls/icon-button/index.js"
56
+ },
57
+ "./icon-button.css": "./src/controls/icon-button/style.css",
58
+ "./input": {
59
+ "types": "./types/controls/input.d.ts",
60
+ "import": "./src/controls/input/index.js"
61
+ },
62
+ "./input.css": "./src/controls/input/style.css",
63
+ "./radio-group": {
64
+ "types": "./types/controls/radio-group.d.ts",
65
+ "import": "./src/controls/radio-group/index.js"
66
+ },
67
+ "./radio-group.css": "./src/controls/radio-group/style.css",
68
+ "./rating": {
69
+ "types": "./types/controls/rating.d.ts",
70
+ "import": "./src/controls/rating/index.js"
71
+ },
72
+ "./rating.css": "./src/controls/rating/style.css",
73
+ "./select": {
74
+ "types": "./types/controls/select.d.ts",
75
+ "import": "./src/controls/select/index.js"
76
+ },
77
+ "./select.css": "./src/controls/select/style.css",
78
+ "./slider": {
79
+ "types": "./types/controls/slider.d.ts",
80
+ "import": "./src/controls/slider/index.js"
81
+ },
82
+ "./slider.css": "./src/controls/slider/style.css",
83
+ "./switch": {
84
+ "types": "./types/controls/switch.d.ts",
85
+ "import": "./src/controls/switch/index.js"
86
+ },
87
+ "./switch.css": "./src/controls/switch/style.css",
88
+ "./card": {
89
+ "types": "./types/widgets/card.d.ts",
90
+ "import": "./src/widgets/card/index.js"
91
+ },
92
+ "./card.css": "./src/widgets/card/style.css",
93
+ "./flex": {
94
+ "types": "./types/layout/flex.d.ts",
95
+ "import": "./src/layout/flex/index.js"
96
+ },
97
+ "./flex.css": "./src/layout/flex/style.css",
98
+ "./grid": {
99
+ "types": "./types/layout/grid.d.ts",
100
+ "import": "./src/layout/grid/index.js"
101
+ },
102
+ "./grid.css": "./src/layout/grid/style.css"
103
+ },
104
+ "files": [
105
+ "src",
106
+ "types",
107
+ "!src/**/*.test.js"
108
+ ],
109
+ "publishConfig": {
110
+ "access": "public"
111
+ },
112
+ "sideEffects": [
113
+ "**/*.css"
114
+ ],
115
+ "peerDependencies": {
116
+ "@inglorious/web": "4.4.0"
117
+ },
118
+ "devDependencies": {
119
+ "@storybook/addon-docs": "^10.2.10",
120
+ "@storybook/web-components-vite": "^10.2.10",
121
+ "happy-dom": "^15.11.0",
122
+ "jsdom": "^25.0.0",
123
+ "prettier": "^3.6.2",
124
+ "storybook": "^10.2.10",
125
+ "vite": "^7.3.1",
126
+ "vitest": "^4.0.15",
127
+ "@inglorious/eslint-config": "1.1.2",
128
+ "@inglorious/web": "4.4.0",
129
+ "@inglorious/store": "9.6.0"
130
+ },
131
+ "engines": {
132
+ "node": ">= 22"
133
+ },
134
+ "scripts": {
135
+ "format": "prettier --write .",
136
+ "lint": "eslint .",
137
+ "test:watch": "vitest",
138
+ "test": "vitest run",
139
+ "storybook": "storybook dev -p 6006",
140
+ "build-storybook": "storybook build"
141
+ }
142
+ }
@@ -0,0 +1,139 @@
1
+ import { html } from "@inglorious/web"
2
+
3
+ import {
4
+ makeStoryRender,
5
+ notifyActionArgType,
6
+ } from "../../stories/notifyStory.js"
7
+ import { button } from "."
8
+
9
+ export default {
10
+ title: "Controls/Button",
11
+ tags: ["autodocs"],
12
+ render: makeStoryRender(button, "story-button"),
13
+ argTypes: {
14
+ ...notifyActionArgType,
15
+ children: {
16
+ control: "text",
17
+ description: "Content displayed inside the button.",
18
+ },
19
+ variant: {
20
+ control: "select",
21
+ options: ["default", "outline", "ghost"],
22
+ description: "Visual style variant.",
23
+ },
24
+ color: {
25
+ control: "select",
26
+ options: ["primary", "secondary", "success", "warning", "error", "info"],
27
+ description: "Semantic color intent.",
28
+ },
29
+ size: {
30
+ control: "select",
31
+ options: ["sm", "md", "lg"],
32
+ description: "Size scale for paddings and font-size.",
33
+ },
34
+ shape: {
35
+ control: "select",
36
+ options: ["rectangle", "pill", "round", "square"],
37
+ description: "Button shape profile.",
38
+ },
39
+ disabled: {
40
+ control: "boolean",
41
+ description: "Disables interaction and click notifications.",
42
+ },
43
+ fullWidth: {
44
+ control: "boolean",
45
+ description: "Expands button width to 100% of its container.",
46
+ },
47
+ type: {
48
+ control: "select",
49
+ options: ["button", "submit", "reset", "menu"],
50
+ description: "Native HTML button type attribute.",
51
+ },
52
+ },
53
+ parameters: {
54
+ docs: {
55
+ description: {
56
+ component:
57
+ "Action control with theme-aware variants, sizes, and semantic colors.",
58
+ },
59
+ },
60
+ actions: {
61
+ handles: ["click"],
62
+ },
63
+ },
64
+ }
65
+ export const Default = {}
66
+ Default.args = {
67
+ children: "Button",
68
+ variant: "default",
69
+ color: "primary",
70
+ size: "md",
71
+ shape: "rectangle",
72
+ disabled: false,
73
+ fullWidth: false,
74
+ type: "button",
75
+ }
76
+
77
+ export const Outline = {}
78
+ Outline.args = {
79
+ ...Default.args,
80
+ variant: "outline",
81
+ }
82
+
83
+ export const Ghost = {}
84
+ Ghost.args = {
85
+ ...Default.args,
86
+ variant: "ghost",
87
+ }
88
+
89
+ export const Small = {}
90
+ Small.args = {
91
+ ...Default.args,
92
+ size: "sm",
93
+ }
94
+
95
+ export const Large = {}
96
+ Large.args = {
97
+ ...Default.args,
98
+ size: "lg",
99
+ }
100
+
101
+ export const Secondary = {}
102
+ Secondary.args = {
103
+ ...Default.args,
104
+ color: "secondary",
105
+ }
106
+
107
+ export const Success = {}
108
+ Success.args = {
109
+ ...Default.args,
110
+ color: "success",
111
+ }
112
+
113
+ export const Disabled = {}
114
+ Disabled.args = {
115
+ ...Default.args,
116
+ disabled: true,
117
+ }
118
+
119
+ export const FullWidth = {}
120
+ FullWidth.args = {
121
+ ...Default.args,
122
+ children: "Full Width Button",
123
+ fullWidth: true,
124
+ }
125
+
126
+ export const Round = {}
127
+ Round.args = {
128
+ ...Default.args,
129
+ shape: "round",
130
+ children: "+",
131
+ }
132
+
133
+ export const CustomContent = {}
134
+ CustomContent.args = {
135
+ ...Default.args,
136
+ children: html`<span style="display: inline-flex; gap: 0.25rem;"
137
+ ><strong>Save</strong><span>⌘S</span></span
138
+ >`,
139
+ }
@@ -0,0 +1,5 @@
1
+ import { withRenderValidation } from "../../shared/withRenderValidation.js"
2
+ import * as renderers from "./template.js"
3
+
4
+ export const buttonPrimitive = { ...renderers }
5
+ export const button = [buttonPrimitive, withRenderValidation]
@@ -0,0 +1,148 @@
1
+ .iw-button {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ gap: var(--iw-space-2);
6
+ padding: var(--iw-space-2) var(--iw-space-4);
7
+ font-family: var(--iw-font-family-sans);
8
+ font-size: var(--iw-font-size-base);
9
+ font-weight: var(--iw-font-weight-medium);
10
+ line-height: var(--iw-line-height-normal);
11
+ text-decoration: none;
12
+ white-space: nowrap;
13
+ cursor: pointer;
14
+ border: 1px solid var(--iw-button-border);
15
+ border-radius: var(--iw-button-radius);
16
+ background-color: var(--iw-button-bg);
17
+ color: var(--iw-button-text);
18
+ box-shadow: var(--iw-button-shadow);
19
+ transition: all var(--iw-transition-fast);
20
+
21
+ &:hover:not(:disabled) {
22
+ background-color: var(--iw-button-bg-hover);
23
+ box-shadow: var(--iw-button-shadow-hover);
24
+ }
25
+
26
+ &:active:not(:disabled) {
27
+ background-color: var(--iw-button-bg-active);
28
+ box-shadow: var(--iw-button-shadow-active);
29
+ }
30
+
31
+ &:disabled,
32
+ &.iw-button-disabled {
33
+ opacity: 0.5;
34
+ cursor: not-allowed;
35
+ }
36
+
37
+ .iw-button-icon {
38
+ display: inline-flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ width: 1em;
42
+ height: 1em;
43
+ }
44
+
45
+ &.iw-button-outline {
46
+ background-color: var(--iw-button-outline-bg);
47
+ color: var(--iw-button-outline-text);
48
+ border-color: var(--iw-button-outline-border);
49
+ box-shadow: none;
50
+
51
+ &:hover:not(:disabled) {
52
+ background-color: var(--iw-button-outline-bg-hover);
53
+ color: var(--iw-button-outline-text-hover);
54
+ box-shadow: none;
55
+ }
56
+ }
57
+
58
+ &.iw-button-ghost {
59
+ background-color: var(--iw-button-ghost-bg);
60
+ color: var(--iw-button-ghost-text);
61
+ border-color: var(--iw-button-ghost-border);
62
+ box-shadow: none;
63
+
64
+ &:hover:not(:disabled) {
65
+ background-color: var(--iw-button-ghost-bg-hover);
66
+ box-shadow: none;
67
+ }
68
+ }
69
+
70
+ &.iw-button-secondary {
71
+ --iw-button-bg: var(--iw-color-gray-600);
72
+ --iw-button-bg-hover: var(--iw-color-gray-700);
73
+ --iw-button-bg-active: var(--iw-color-gray-800);
74
+ --iw-button-border: var(--iw-color-gray-600);
75
+ }
76
+
77
+ &.iw-button-success {
78
+ --iw-button-bg: var(--iw-color-success);
79
+ --iw-button-bg-hover: var(--iw-color-success-dark);
80
+ --iw-button-bg-active: #064e3b;
81
+ --iw-button-border: var(--iw-color-success);
82
+ }
83
+
84
+ &.iw-button-warning {
85
+ --iw-button-bg: var(--iw-color-warning);
86
+ --iw-button-bg-hover: var(--iw-color-warning-dark);
87
+ --iw-button-bg-active: #78350f;
88
+ --iw-button-border: var(--iw-color-warning);
89
+ --iw-button-text: var(--iw-color-black);
90
+ }
91
+
92
+ &.iw-button-error {
93
+ --iw-button-bg: var(--iw-color-error);
94
+ --iw-button-bg-hover: var(--iw-color-error-dark);
95
+ --iw-button-bg-active: #7f1d1d;
96
+ --iw-button-border: var(--iw-color-error);
97
+ }
98
+
99
+ &.iw-button-info {
100
+ --iw-button-bg: var(--iw-color-info);
101
+ --iw-button-bg-hover: var(--iw-color-info-dark);
102
+ --iw-button-bg-active: #1e3a8a;
103
+ --iw-button-border: var(--iw-color-info);
104
+ }
105
+
106
+ &.iw-button-sm {
107
+ padding: var(--iw-space-1) var(--iw-space-3);
108
+ font-size: var(--iw-font-size-sm);
109
+ }
110
+
111
+ &.iw-button-lg {
112
+ padding: var(--iw-space-3) var(--iw-space-6);
113
+ font-size: var(--iw-font-size-lg);
114
+ }
115
+
116
+ &.iw-button-full-width {
117
+ width: 100%;
118
+ }
119
+
120
+ &.iw-button-shape-pill {
121
+ border-radius: 999px;
122
+ }
123
+
124
+ &.iw-button-shape-round,
125
+ &.iw-button-shape-square {
126
+ width: 2.5rem;
127
+ aspect-ratio: 1 / 1;
128
+ padding: 0;
129
+ }
130
+
131
+ &.iw-button-shape-round {
132
+ border-radius: 999px;
133
+ }
134
+
135
+ &.iw-button-shape-square {
136
+ border-radius: var(--iw-radius-sm);
137
+ }
138
+
139
+ &.iw-button-sm.iw-button-shape-round,
140
+ &.iw-button-sm.iw-button-shape-square {
141
+ width: 2rem;
142
+ }
143
+
144
+ &.iw-button-lg.iw-button-shape-round,
145
+ &.iw-button-lg.iw-button-shape-square {
146
+ width: 3rem;
147
+ }
148
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @typedef {import('../../../types/controls/button').ButtonEntity} ButtonEntity
3
+ * @typedef {import('@inglorious/web').Api} Api
4
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
+ */
6
+
7
+ import { classMap, html, ref } from "@inglorious/web"
8
+
9
+ import { applyElementProps } from "@/shared/applyElementProps.js"
10
+
11
+ /**
12
+ * Button type for Inglorious Web.
13
+ *
14
+ * @example
15
+ * // Stateless usage
16
+ * button.render({ children: 'Click me', variant: 'primary' }, api)
17
+ *
18
+ * @example
19
+ * // Stateful usage with event handling
20
+ * // Entity: { type: 'button', id: 'submitBtn', children: 'Submit' }
21
+ * // In store: api.render('submitBtn')
22
+ *
23
+ * @param {ButtonEntity} entity
24
+ * @param {Api} api
25
+ * @returns {TemplateResult}
26
+ */
27
+ export function render(entity, api) {
28
+ const {
29
+ children,
30
+ variant = "default",
31
+ color = "primary",
32
+ size = "md",
33
+ shape = "rectangle",
34
+ disabled = false,
35
+ fullWidth = false,
36
+ type = "button",
37
+ ariaLabel = "",
38
+ ariaPressed = false,
39
+ className = "",
40
+ ...rest
41
+ } = entity
42
+
43
+ const extraClasses = Object.fromEntries(
44
+ className
45
+ .split(/\s+/)
46
+ .filter(Boolean)
47
+ .map((name) => [name, true]),
48
+ )
49
+
50
+ const classes = {
51
+ "iw-button": true,
52
+ [`iw-button-${variant}`]: variant !== "default",
53
+ [`iw-button-${color}`]: color !== "primary",
54
+ [`iw-button-${size}`]: size !== "md",
55
+ [`iw-button-shape-${shape}`]: shape !== "rectangle",
56
+ "iw-button-full-width": fullWidth,
57
+ "iw-button-disabled": disabled,
58
+ ...extraClasses,
59
+ }
60
+
61
+ return html`
62
+ <button
63
+ type=${type}
64
+ aria-label=${ariaLabel}
65
+ aria-pressed=${ariaPressed}
66
+ class=${classMap(classes)}
67
+ ?disabled=${disabled}
68
+ @click=${() => api.notify(`#${entity.id}:click`)}
69
+ ${ref((element) => applyElementProps(element, rest))}
70
+ >
71
+ ${children}
72
+ </button>
73
+ `
74
+ }
@@ -0,0 +1,108 @@
1
+ import {
2
+ makeStoryRender,
3
+ notifyActionArgType,
4
+ } from "../../stories/notifyStory.js"
5
+ import { buttonGroup } from "."
6
+
7
+ export default {
8
+ title: "Controls/ButtonGroup",
9
+ tags: ["autodocs"],
10
+ render: makeStoryRender(buttonGroup, "story-button-group"),
11
+ argTypes: {
12
+ ...notifyActionArgType,
13
+ value: {
14
+ control: "object",
15
+ description:
16
+ "Selected value(s). String for single mode, array for multiple mode.",
17
+ },
18
+ multiple: {
19
+ control: "boolean",
20
+ description: "Enable multi-selection mode.",
21
+ },
22
+ direction: {
23
+ control: "select",
24
+ options: ["row", "column"],
25
+ description: "Group direction.",
26
+ },
27
+ attached: {
28
+ control: "boolean",
29
+ description: "Visually attach adjacent buttons.",
30
+ },
31
+ size: {
32
+ control: "select",
33
+ options: ["sm", "md", "lg"],
34
+ description: "Default size for items.",
35
+ },
36
+ variant: {
37
+ control: "select",
38
+ options: ["default", "outline", "ghost"],
39
+ description: "Default variant for items.",
40
+ },
41
+ color: {
42
+ control: "select",
43
+ options: ["primary", "secondary", "success", "warning", "error", "info"],
44
+ description: "Default color intent for items.",
45
+ },
46
+ disabled: {
47
+ control: "boolean",
48
+ description: "Disables all buttons.",
49
+ },
50
+ buttons: {
51
+ control: "object",
52
+ description: "Items rendered as grouped buttons.",
53
+ },
54
+ },
55
+ parameters: {
56
+ docs: {
57
+ description: {
58
+ component: "Grouped action buttons with attached or spaced layout.",
59
+ },
60
+ },
61
+ },
62
+ }
63
+
64
+ export const Default = {}
65
+ Default.args = {
66
+ value: "",
67
+ multiple: false,
68
+ direction: "row",
69
+ attached: true,
70
+ size: "md",
71
+ variant: "outline",
72
+ color: "primary",
73
+ disabled: false,
74
+ buttons: [
75
+ { id: "left", value: "left", label: "Left" },
76
+ { id: "center", value: "center", label: "Center" },
77
+ { id: "right", value: "right", label: "Right" },
78
+ ],
79
+ }
80
+
81
+ export const Vertical = {}
82
+ Vertical.args = {
83
+ ...Default.args,
84
+ direction: "column",
85
+ }
86
+
87
+ export const SingleSelection = {}
88
+ SingleSelection.args = {
89
+ ...Default.args,
90
+ value: "center",
91
+ buttons: [
92
+ { id: "left", value: "left", label: "Left" },
93
+ { id: "center", value: "center", label: "Center" },
94
+ { id: "right", value: "right", label: "Right" },
95
+ ],
96
+ }
97
+
98
+ export const MultiSelection = {}
99
+ MultiSelection.args = {
100
+ ...Default.args,
101
+ multiple: true,
102
+ value: ["left", "right"],
103
+ buttons: [
104
+ { id: "left", value: "left", label: "Left" },
105
+ { id: "center", value: "center", label: "Center" },
106
+ { id: "right", value: "right", label: "Right" },
107
+ ],
108
+ }
@@ -0,0 +1,4 @@
1
+ import { withRenderValidation } from "../../shared/withRenderValidation.js"
2
+ import * as renderers from "./template.js"
3
+
4
+ export const buttonGroup = [{ ...renderers }, withRenderValidation]
@@ -0,0 +1,58 @@
1
+ .iw-button-group {
2
+ display: inline-flex;
3
+
4
+ &.iw-button-group-column {
5
+ flex-direction: column;
6
+ }
7
+
8
+ &.iw-button-group-row {
9
+ flex-direction: row;
10
+ }
11
+
12
+ &.iw-button-group-attached.iw-button-group-row .iw-button {
13
+ border-radius: 0;
14
+ }
15
+
16
+ &.iw-button-group-attached.iw-button-group-row .iw-button:first-child {
17
+ border-top-left-radius: var(--iw-button-radius);
18
+ border-bottom-left-radius: var(--iw-button-radius);
19
+ }
20
+
21
+ &.iw-button-group-attached.iw-button-group-row .iw-button:last-child {
22
+ border-top-right-radius: var(--iw-button-radius);
23
+ border-bottom-right-radius: var(--iw-button-radius);
24
+ }
25
+
26
+ &.iw-button-group-attached.iw-button-group-row .iw-button + .iw-button {
27
+ margin-left: -1px;
28
+ }
29
+
30
+ &.iw-button-group-attached.iw-button-group-column .iw-button {
31
+ border-radius: 0;
32
+ }
33
+
34
+ &.iw-button-group-attached.iw-button-group-column .iw-button:first-child {
35
+ border-top-left-radius: var(--iw-button-radius);
36
+ border-top-right-radius: var(--iw-button-radius);
37
+ }
38
+
39
+ &.iw-button-group-attached.iw-button-group-column .iw-button:last-child {
40
+ border-bottom-left-radius: var(--iw-button-radius);
41
+ border-bottom-right-radius: var(--iw-button-radius);
42
+ }
43
+
44
+ &.iw-button-group-attached.iw-button-group-column .iw-button + .iw-button {
45
+ margin-top: -1px;
46
+ }
47
+
48
+ &:not(.iw-button-group-attached) {
49
+ gap: var(--iw-space-2);
50
+ }
51
+
52
+ &.iw-button-group-selection .iw-button.iw-button-pressed {
53
+ background-color: var(--iw-button-bg-active);
54
+ border-color: var(--iw-button-bg-active);
55
+ color: var(--iw-button-text);
56
+ box-shadow: var(--iw-button-shadow-active);
57
+ }
58
+ }