@ayu-sh-kr/dota-ui 0.0.1

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 (74) hide show
  1. package/dist/app.config.d.ts +2 -0
  2. package/dist/components/accordian/accordion.component.d.ts +16 -0
  3. package/dist/components/accordian/accordion.config.d.ts +21 -0
  4. package/dist/components/avatar/avatar.component.d.ts +25 -0
  5. package/dist/components/badge/badge.component.d.ts +14 -0
  6. package/dist/components/badge/badge.config.d.ts +75 -0
  7. package/dist/components/button/button.component.d.ts +23 -0
  8. package/dist/components/button/button.config.d.ts +9 -0
  9. package/dist/components/card/card.component.d.ts +33 -0
  10. package/dist/components/chip/chip.component.d.ts +11 -0
  11. package/dist/components/chip/chip.config.d.ts +30 -0
  12. package/dist/components/icon/icons.component.d.ts +15 -0
  13. package/dist/components/icon/icons.config.d.ts +19 -0
  14. package/dist/components/index.d.ts +11 -0
  15. package/dist/components/modal/modal.component.d.ts +16 -0
  16. package/dist/components/modal/modal.config.d.ts +56 -0
  17. package/dist/components/placeholder/placeholder.component.d.ts +6 -0
  18. package/dist/components/popover/popover.component.d.ts +25 -0
  19. package/dist/components/test/count-button.component.d.ts +9 -0
  20. package/dist/components/test/counter.component.d.ts +7 -0
  21. package/dist/components/utils/scaffold.component.d.ts +7 -0
  22. package/dist/dota-ui.d.ts +2 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.mjs +3272 -0
  25. package/dist/main.d.ts +1 -0
  26. package/dist/style-BbqE44zC.css +222 -0
  27. package/dist/utils/debounce.d.ts +25 -0
  28. package/dist/utils/index.d.ts +3 -0
  29. package/dist/utils/position-calculator.utils.d.ts +69 -0
  30. package/dist/utils/position.utils.d.ts +106 -0
  31. package/dist/vite.svg +1 -0
  32. package/index.html +13 -0
  33. package/package.json +34 -0
  34. package/postcss.config.js +6 -0
  35. package/public/vite.svg +1 -0
  36. package/src/app.config.ts +136 -0
  37. package/src/app.d.ts +28 -0
  38. package/src/components/accordian/accordion.component.ts +79 -0
  39. package/src/components/accordian/accordion.config.ts +27 -0
  40. package/src/components/accordian/accordion.css +19 -0
  41. package/src/components/avatar/avatar.component.ts +195 -0
  42. package/src/components/badge/badge.component.ts +49 -0
  43. package/src/components/badge/badge.config.ts +85 -0
  44. package/src/components/button/button.component.ts +118 -0
  45. package/src/components/button/button.config.ts +66 -0
  46. package/src/components/button/button.css +96 -0
  47. package/src/components/card/card.component.ts +145 -0
  48. package/src/components/chip/chip.component.ts +44 -0
  49. package/src/components/chip/chip.config.ts +33 -0
  50. package/src/components/icon/icons.component.ts +83 -0
  51. package/src/components/icon/icons.config.ts +24 -0
  52. package/src/components/index.ts +11 -0
  53. package/src/components/modal/modal.component.ts +67 -0
  54. package/src/components/modal/modal.config.ts +69 -0
  55. package/src/components/modal/modal.css +50 -0
  56. package/src/components/placeholder/placeholder.component.ts +25 -0
  57. package/src/components/placeholder/placeholder.css +3 -0
  58. package/src/components/popover/popover.component.ts +127 -0
  59. package/src/components/popover/popover.css +7 -0
  60. package/src/components/test/count-button.component.ts +48 -0
  61. package/src/components/test/counter.component.ts +37 -0
  62. package/src/components/utils/scaffold.component.ts +27 -0
  63. package/src/index.ts +2 -0
  64. package/src/main.ts +2 -0
  65. package/src/style.css +7 -0
  66. package/src/typescript.svg +1 -0
  67. package/src/utils/debounce.ts +37 -0
  68. package/src/utils/index.ts +4 -0
  69. package/src/utils/position-calculator.utils.ts +122 -0
  70. package/src/utils/position.utils.ts +243 -0
  71. package/src/vite-env.d.ts +1 -0
  72. package/tailwind.config.ts +13 -0
  73. package/tsconfig.json +41 -0
  74. package/vite.config.ts +46 -0
package/src/app.d.ts ADDED
@@ -0,0 +1,28 @@
1
+
2
+ declare interface UIConfig {
3
+ base: string
4
+ color: UIColor,
5
+ size: UISize,
6
+ rounded: UIRounded
7
+ animation: any
8
+ }
9
+
10
+ declare interface UIColor {
11
+ [name: string]: ColorVariants
12
+ }
13
+
14
+ declare interface ColorVariants {
15
+ solid: string;
16
+ soft: string;
17
+ outline: string;
18
+ ghost: string;
19
+ link : string
20
+ }
21
+
22
+ declare interface UISize {
23
+ [name: string]: string
24
+ }
25
+
26
+ declare interface UIRounded {
27
+ [name: string]: string
28
+ }
@@ -0,0 +1,79 @@
1
+ import {BaseElement, BindEvent, Component, Property, String} from "@ayu-sh-kr/dota-core/dist";
2
+ import "@dota/components/icon/icons.component.ts";
3
+ import './accordion.css';
4
+ import {AccordionStyle} from "@dota/components/accordian/accordion.config.ts";
5
+ import type {AccordionColor, AccordionSize, AccordionVariant} from "@dota/components/accordian/accordion.config.ts";
6
+
7
+ @Component({
8
+ selector: 'dota-accordion',
9
+ shadow: false
10
+ })
11
+ class AccordionComponent extends BaseElement {
12
+
13
+ @Property({name: 'classname', type: String})
14
+ className!: string;
15
+
16
+ @Property({name: 'header', type: String})
17
+ header!: string;
18
+
19
+ @Property({name: 'description', type: String})
20
+ description!: string;
21
+
22
+ @Property({name: 'icon', type: String})
23
+ icon!: string;
24
+
25
+ @Property({name: 'color', type: String})
26
+ color!: AccordionColor;
27
+
28
+ @Property({name: 'variant', type: String})
29
+ variant!: AccordionVariant
30
+
31
+ @Property({name: 'size', type: String})
32
+ size!: AccordionSize
33
+
34
+ constructor() {
35
+ super();
36
+ }
37
+
38
+
39
+ @BindEvent({event: 'click', id: '#header'})
40
+ handleAccordion() {
41
+ const element = this.querySelector('#description');
42
+ if (element) {
43
+ element.classList.toggle('description-active');
44
+ }
45
+
46
+ const icon = this.querySelector('#icon');
47
+
48
+ if (icon) {
49
+ icon.classList.toggle('active');
50
+ }
51
+ }
52
+
53
+ processIcon = (icon: string) => {
54
+ return icon ? `<dota-icon className="text-blue-400 text-xl" name="${icon}"></dota-icon>` : '';
55
+ }
56
+
57
+
58
+ render(): string {
59
+ return `
60
+ <div class="${this.className ?? ''} w-full flex flex-col">
61
+ <button type="button" id="header" class="${AccordionStyle.button.base} ${AccordionStyle.button.size[this.size] ?? AccordionStyle.button.size.md} ${AccordionStyle.button.color[this.color][`${this.variant ?? 'solid'}`] ?? AccordionStyle.button.color.gray.soft}">
62
+ <div class="flex">
63
+ ${this.processIcon(this.icon)}
64
+ <span class="text-left break-all line-clamp-1">${this.header}</span>
65
+ </div>
66
+ <div id="icon" class="icon">
67
+ <dota-icon name="material-symbols:arrow-forward-ios-rounded"></dota-icon>
68
+ </div>
69
+ </button>
70
+ <div id="description" class="description">
71
+ <p class="overflow-hidden p-2 ${AccordionStyle.paragraph}">${this.description}</p>
72
+ </div>
73
+ </div>
74
+ `
75
+ }
76
+ }
77
+
78
+
79
+ export {AccordionComponent, AccordionStyle as AccordionConfig, type AccordionColor, type AccordionSize, type AccordionVariant}
@@ -0,0 +1,27 @@
1
+ import {UIConfig} from "@dota/app.config.ts";
2
+
3
+ export const AccordionStyle = {
4
+
5
+ button: {
6
+ base: 'focus:outline-none focus-visible:outline-0 disabled:cursor-not-allowed disabled:opacity-75 flex-shrink-0 font-medium rounded-md inline-flex justify-between items-center mb-1.5 w-full',
7
+ size: {
8
+ '2xs': 'text-xs gap-x-1 px-2 py-1',
9
+ xs: 'text-xs gap-x-1.5 px-2.5 py-1.5',
10
+ sm: 'text-sm gap-x-1.5 px-2.5 py-1.5',
11
+ md: 'text-sm gap-x-2 px-3 py-2',
12
+ lg: 'text-sm gap-x-2.5 px-3.5 py-2.5',
13
+ xl: 'text-base gap-x-2.5 px-3.5 py-2.5'
14
+ },
15
+ color: {
16
+ ...UIConfig.color
17
+ },
18
+ },
19
+ paragraph: 'text-sm text-gray-500 dark:text-gray-400 pt-1.5 pb-3'
20
+
21
+ }
22
+
23
+ type AccordionColor = keyof typeof AccordionStyle.button.color;
24
+ type AccordionSize = keyof typeof AccordionStyle.button.size;
25
+ type AccordionVariant = keyof ColorVariants;
26
+
27
+ export type {AccordionSize, AccordionColor, AccordionVariant}
@@ -0,0 +1,19 @@
1
+ .header {
2
+ @apply cursor-pointer flex items-center justify-between border px-4 py-2
3
+ }
4
+
5
+ .icon {
6
+ transition: transform 0.2s;
7
+ }
8
+
9
+ .icon.active {
10
+ transform: rotate(90deg);
11
+ }
12
+
13
+ .description {
14
+ @apply h-0 transform duration-300 ease-in overflow-hidden transition-[height]
15
+ }
16
+
17
+ .description-active {
18
+ @apply h-fit duration-300 transform ease-in text-lg transition-[height]
19
+ }
@@ -0,0 +1,195 @@
1
+ import {BaseElement, Component, Property, Boolean, String} from "@ayu-sh-kr/dota-core/dist";
2
+ import {type IconColor, type IconSize, IconStyle, type IconVariant} from "@dota/components";
3
+
4
+
5
+ @Component({
6
+ selector: 'd-avatar',
7
+ shadow: false
8
+ })
9
+ export class AvatarComponent extends BaseElement {
10
+
11
+ @Property({
12
+ name: 'img',
13
+ type: String
14
+ })
15
+ img!: string
16
+
17
+ @Property({
18
+ name: 'img-alt',
19
+ type: String
20
+ })
21
+ imgAlt!: string
22
+
23
+ @Property({
24
+ name: 'label',
25
+ type: String
26
+ })
27
+ label!: string;
28
+
29
+ @Property({
30
+ name: 'icon',
31
+ type: String
32
+ })
33
+ icon!: string;
34
+
35
+ @Property({
36
+ name: 'is-chip',
37
+ type: Boolean
38
+ })
39
+ isChip!: boolean;
40
+
41
+ @Property({
42
+ name: 'chip-text',
43
+ type: String
44
+ })
45
+ chipText!: string;
46
+
47
+ @Property({
48
+ name: 'chip-color',
49
+ type: String
50
+ })
51
+ chipColor!: string;
52
+
53
+ @Property({
54
+ name: 'chip-position',
55
+ type: String
56
+ })
57
+ chipPosition!: string
58
+
59
+ @Property({
60
+ name: 'variant',
61
+ type: String
62
+ })
63
+ variant!: string;
64
+
65
+ @Property({
66
+ name: 'size',
67
+ type: String
68
+ })
69
+ size!: string
70
+
71
+ constructor() {
72
+ super();
73
+ }
74
+
75
+ template = (): string => {
76
+
77
+ const size = this.size || 'md';
78
+
79
+ if(this.img) {
80
+ return this.isChip ?
81
+ `
82
+ <dota-chip color="${this.chipColor}" size="sm" position="${this.chipPosition}">
83
+ <avatar-wrapper color="${this.chipColor}" variant="${this.variant}" size="${size}">
84
+ <img src="${this.img}" alt="${this.imgAlt}" class="w-full h-full">
85
+ </avatar-wrapper>
86
+ </dota-chip>
87
+
88
+ ` :
89
+ `
90
+ <avatar-wrapper color="${this.chipColor}" variant="${this.variant}" size="${size}">
91
+ <img src="${this.img}" alt="${this.imgAlt}" class="w-full h-full">
92
+ </avatar-wrapper>
93
+ `;
94
+ } else if(this.label) {
95
+ return this.isChip ?
96
+ `
97
+ <dota-chip color="${this.chipColor}" size="sm" position="${this.chipPosition}">
98
+ <avatar-wrapper color="${this.chipColor}" variant="${this.variant}" size="${size}">
99
+ ${this.label.split(" ").map((value: string, index: number) => {
100
+ if(index < 2) {
101
+ return value.toUpperCase().at(0);
102
+ }
103
+ }).join("")}
104
+ </avatar-wrapper>
105
+ </dota-chip>
106
+ `
107
+ :
108
+ `
109
+ <avatar-wrapper color="${this.chipColor}" variant="${this.variant}" size="${size}">
110
+ <span>
111
+ ${this.label.split(" ").map((value: string, index: number) => {
112
+ if(index < 2) {
113
+ return value.toUpperCase().at(0);
114
+ }
115
+ }).join("")}
116
+ </span>
117
+ </avatar-wrapper>
118
+ `;
119
+ } else {
120
+
121
+ return this.isChip ?
122
+ `
123
+ <dota-chip color="${this.chipColor}" size="sm" position="${this.chipPosition}">
124
+ <avatar-wrapper color="${this.chipColor}" variant="${this.variant}" size="${size}">
125
+ <dota-icon name="${this.icon}" color="${this.chipColor}" size="${size}" variant="${this.variant}"></dota-icon>
126
+ </avatar-wrapper>
127
+ </dota-chip>
128
+ `
129
+ :
130
+ `
131
+ <avatar-wrapper color="${this.chipColor}" variant="${this.variant}" size="${size}">
132
+ <dota-icon name="${this.icon}" color="${this.chipColor}" size="${size}" variant="${this.variant}"></dota-icon>
133
+ </avatar-wrapper>
134
+ `;
135
+ }
136
+ }
137
+
138
+ render(): string {
139
+ return this.template();
140
+ }
141
+
142
+ }
143
+
144
+ @Component({
145
+ selector: 'avatar-wrapper',
146
+ shadow: false
147
+ })
148
+ export class AvatarWrapper extends BaseElement {
149
+
150
+ content!: string
151
+
152
+ @Property({
153
+ name: 'color',
154
+ type: String
155
+ })
156
+ color!: IconColor;
157
+
158
+
159
+ @Property({
160
+ name: 'variant',
161
+ type: String
162
+ })
163
+ variant!: IconVariant;
164
+
165
+ @Property({
166
+ name: 'size',
167
+ type: String
168
+ })
169
+ size!: IconSize
170
+
171
+ constructor() {
172
+ super();
173
+ this.content = this.innerHTML;
174
+ }
175
+
176
+ render(): string {
177
+
178
+ const color = AvatarConfig.color[this.color] || AvatarConfig.color.gray;
179
+ const variant = color[this.variant] || color.solid
180
+
181
+ const size = AvatarConfig.size[this.size] || AvatarConfig.size.lg;
182
+
183
+ return `
184
+ <div class="rounded-full content-center ${variant} ${size} flex items-center justify-center font-semibold overflow-hidden">
185
+ ${this.content}
186
+ </div>
187
+ `;
188
+ }
189
+
190
+ }
191
+
192
+ const AvatarConfig = {
193
+ color: IconStyle.color,
194
+ size: IconStyle.size
195
+ }
@@ -0,0 +1,49 @@
1
+ import {BaseElement, Component, Property, String} from "@ayu-sh-kr/dota-core/dist";
2
+
3
+ import {BadgeStyle} from "@dota/components/badge/badge.config.ts";
4
+ import type {BadgeColor, BadgeRounded, BadgeSize, BadgeVariants} from "@dota/components/badge/badge.config.ts";
5
+
6
+ @Component({
7
+ selector: 'dota-badge',
8
+ shadow: false
9
+ })
10
+ class BadgeComponent extends BaseElement {
11
+
12
+ @Property({name: 'classname', type: String})
13
+ className!: string
14
+
15
+ @Property({name: 'color', type: String})
16
+ color!: BadgeColor
17
+
18
+ @Property({name: 'variant', type: String})
19
+ variant!: BadgeVariants;
20
+
21
+ @Property({name: 'size', type: String})
22
+ size!: BadgeSize
23
+
24
+ @Property({name: 'rounded', type: String})
25
+ rounded!: BadgeRounded;
26
+
27
+ @Property({name: 'label', type: String})
28
+ label!: string;
29
+
30
+ content!: string;
31
+
32
+ constructor() {
33
+ super();
34
+ this.content = this.innerHTML;
35
+ this.counter = 0;
36
+ }
37
+
38
+ render(): string {
39
+ return `
40
+ <span id="click" class="${BadgeStyle.base} ${BadgeStyle['color'][`${this.color ?? 'red'}`][`${this.variant ?? 'solid'}`]} ${BadgeStyle.size[`${this.size ?? ''}`]} ${BadgeStyle.rounded[`${this.rounded ?? 'none'}`]} ${this.className ?? ''}">
41
+ ${this.label ? this.label : this.content}
42
+ </span>
43
+ `
44
+ }
45
+
46
+ }
47
+
48
+ export {BadgeComponent, BadgeStyle as BadgeConfig};
49
+
@@ -0,0 +1,85 @@
1
+
2
+
3
+ const BadgeStyle = {
4
+ base: 'inline-flex item-center text-center w-fit px-3 py-1',
5
+
6
+ rounded: {
7
+ 'none': '',
8
+ 'sm': 'rounded-sm',
9
+ 'md': 'rounded-md',
10
+ 'lg': 'rounded-lg',
11
+ 'xl': 'rounded-xl'
12
+ },
13
+
14
+ size: {
15
+ xs: 'text-xs',
16
+ sm: 'text-sm',
17
+ lg: 'text-lg',
18
+ xl: 'text-xl',
19
+ '2xl': 'text-2xl',
20
+ '3xl': 'text-3xl',
21
+ '4xl': 'text-4xl'
22
+ },
23
+
24
+ color: {
25
+ red: {
26
+ solid: 'bg-red-500 dark:bg-red-400 text-white dark:text-gray-900',
27
+ outline: 'text-red-500 dark:text-red-400 ring-1 ring-inset ring-red-500 dark:ring-red-400',
28
+ soft: 'bg-red-50 dark:bg-red-400 dark:bg-opacity-10 text-red-500 dark:text-red-400',
29
+ subtle: 'bg-red-50 dark:bg-red-400 dark:bg-opacity-10 text-red-500 dark:text-red-400 ring-1 ring-inset ring-red-500 dark:ring-red-400 ring-opacity-25 dark:ring-opacity-25',
30
+ },
31
+ yellow: {
32
+ solid: 'bg-yellow-500 dark:bg-yellow-400 text-white dark:text-gray-900',
33
+ outline: 'text-yellow-500 dark:text-yellow-400 ring-1 ring-inset ring-yellow-500 dark:ring-yellow-400',
34
+ soft: 'bg-yellow-50 dark:bg-yellow-400 dark:bg-opacity-10 text-yellow-500 dark:text-yellow-400',
35
+ subtle: 'bg-yellow-50 dark:bg-yellow-400 dark:bg-opacity-10 text-yellow-500 dark:text-yellow-400 ring-1 ring-inset ring-yellow-500 dark:ring-yellow-400 ring-opacity-25 dark:ring-opacity-25',
36
+ },
37
+ pink: {
38
+ solid: 'bg-pink-500 dark:bg-pink-400 text-white dark:text-gray-900',
39
+ outline: 'text-pink-500 dark:text-pink-400 ring-1 ring-inset ring-pink-500 dark:ring-pink-400',
40
+ soft: 'bg-pink-50 dark:bg-pink-400 dark:bg-opacity-10 text-pink-500 dark:text-pink-400',
41
+ subtle: 'bg-pink-50 dark:bg-pink-400 dark:bg-opacity-10 text-pink-500 dark:text-pink-400 ring-1 ring-inset ring-pink-500 dark:ring-pink-400 ring-opacity-25 dark:ring-opacity-25',
42
+ },
43
+ purple: {
44
+ solid: 'bg-purple-500 dark:bg-purple-400 text-white dark:text-gray-900',
45
+ outline: 'text-purple-500 dark:text-purple-400 ring-1 ring-inset ring-purple-500 dark:ring-purple-400',
46
+ soft: 'bg-purple-50 dark:bg-purple-400 dark:bg-opacity-10 text-purple-500 dark:text-purple-400',
47
+ subtle: 'bg-purple-50 dark:bg-purple-400 dark:bg-opacity-10 text-purple-500 dark:text-purple-400 ring-1 ring-inset ring-purple-500 dark:ring-purple-400 ring-opacity-25 dark:ring-opacity-25',
48
+ },
49
+ blue: {
50
+ solid: 'bg-blue-500 dark:bg-blue-400 text-white dark:text-gray-900',
51
+ outline: 'text-blue-500 dark:text-blue-400 ring-1 ring-inset ring-blue-500 dark:ring-blue-400',
52
+ soft: 'bg-blue-50 dark:bg-blue-400 dark:bg-opacity-10 text-blue-500 dark:text-blue-400',
53
+ subtle: 'bg-blue-50 dark:bg-blue-400 dark:bg-opacity-10 text-blue-500 dark:text-blue-400 ring-1 ring-inset ring-blue-500 dark:ring-blue-400 ring-opacity-25 dark:ring-opacity-25',
54
+ },
55
+ cyan: {
56
+ solid: 'bg-cyan-500 dark:bg-cyan-400 text-white dark:text-gray-900',
57
+ outline: 'text-cyan-500 dark:text-cyan-400 ring-1 ring-inset ring-cyan-500 dark:ring-cyan-400',
58
+ soft: 'bg-cyan-50 dark:bg-cyan-400 dark:bg-opacity-10 text-cyan-500 dark:text-cyan-400',
59
+ subtle: 'bg-cyan-50 dark:bg-cyan-400 dark:bg-opacity-10 text-cyan-500 dark:text-cyan-400 ring-1 ring-inset ring-cyan-500 dark:ring-cyan-400 ring-opacity-25 dark:ring-opacity-25',
60
+ },
61
+ green: {
62
+ solid: 'bg-green-500 dark:bg-green-400 text-white dark:text-gray-900',
63
+ outline: 'text-green-500 dark:text-green-400 ring-1 ring-inset ring-green-500 dark:ring-green-400',
64
+ soft: 'bg-green-50 dark:bg-green-400 dark:bg-opacity-10 text-green-500 dark:text-green-400',
65
+ subtle: 'bg-green-50 dark:bg-green-400 dark:bg-opacity-10 text-green-500 dark:text-green-400 ring-1 ring-inset ring-green-500 dark:ring-green-400 ring-opacity-25 dark:ring-opacity-25',
66
+ },
67
+ emerald: {
68
+ solid: 'bg-emerald-500 dark:bg-emerald-400 text-white dark:text-gray-900',
69
+ outline: 'text-emerald-500 dark:text-emerald-400 ring-1 ring-inset ring-emerald-500 dark:ring-emerald-400',
70
+ soft: 'bg-emerald-50 dark:bg-emerald-400 dark:bg-opacity-10 text-emerald-500 dark:text-emerald-400',
71
+ subtle: 'bg-emerald-50 dark:bg-emerald-400 dark:bg-opacity-10 text-emerald-500 dark:text-emerald-400 ring-1 ring-inset ring-emerald-500 dark:ring-emerald-400 ring-opacity-25 dark:ring-opacity-25',
72
+ }
73
+ }
74
+ }
75
+
76
+ type BadgeVariants = keyof typeof BadgeStyle.color.red;
77
+
78
+ type BadgeColor = keyof typeof BadgeStyle.color
79
+
80
+ type BadgeSize = keyof typeof BadgeStyle.size;
81
+
82
+ type BadgeRounded = keyof typeof BadgeStyle.rounded;
83
+
84
+ export {BadgeStyle}
85
+ export type {BadgeVariants, BadgeRounded, BadgeSize, BadgeColor}
@@ -0,0 +1,118 @@
1
+ import {BaseElement, Component, Property, String, Boolean} from "@ayu-sh-kr/dota-core/dist";
2
+ import {
3
+ type ButtonAnimation, type ButtonAnimationColor,
4
+ type ButtonRound, type ButtonSize,
5
+ ButtonStyle, type ButtonVariants, type IconPosition
6
+ } from "@dota/components/button/button.config.ts";
7
+ import './button.css'
8
+ import {type UIColor} from "@dota/app.config.ts";
9
+
10
+ @Component({
11
+ selector: 'dota-button',
12
+ shadow: false
13
+ })
14
+ class ButtonComponent extends BaseElement {
15
+ content!: string;
16
+
17
+ @Property({name: 'animation', type: String})
18
+ animation!: ButtonAnimation
19
+
20
+ @Property({name: 'className', type: String})
21
+ className!: string
22
+
23
+ @Property({name: "label", type: String})
24
+ label!: string;
25
+
26
+ @Property({name: 'color', type: String})
27
+ color!: UIColor
28
+
29
+ @Property({name: "variant", type: String})
30
+ variant!: ButtonVariants;
31
+
32
+ @Property({name:"icon", type: String})
33
+ icon!:string;
34
+
35
+ @Property({name: 'loading', type: Boolean})
36
+ loading!: boolean
37
+
38
+ @Property({name: 'icon-position', type: String})
39
+ iconPosition!: IconPosition
40
+
41
+ @Property({name: 'animation-color', type: String})
42
+ animationColor!: ButtonAnimationColor;
43
+
44
+ @Property({name: 'type', type: String})
45
+ type!: string;
46
+
47
+ @Property({name: 'size', type: String})
48
+ size!: ButtonSize
49
+
50
+ @Property({name: 'round', type: String})
51
+ rounded!: ButtonRound
52
+
53
+ constructor() {
54
+ super();
55
+ this.content = this.innerHTML;
56
+
57
+ }
58
+
59
+
60
+ template = (): string => {
61
+
62
+ const iconComponent = this.icon ? `<dota-icon class="relative block" name="${this.icon}" size="${this.size || 'md'}"></dota-icon>` : '';
63
+ const size = ButtonStyle.size?.[this.size ?? "md"] ?? '';
64
+ const round = ButtonStyle.rounded?.[this.rounded] ?? '';
65
+
66
+ let content: string;
67
+ switch (this.iconPosition) {
68
+ case "forward": {
69
+ content = `
70
+ <p>${this.label || this.content}</p>
71
+ ${iconComponent}
72
+ `
73
+ break
74
+ }
75
+
76
+ case "leading": {
77
+ content = `
78
+ ${iconComponent}
79
+ <p>${this.label || this.content}</p>
80
+ `
81
+ break
82
+ }
83
+
84
+ default: {
85
+ content = `
86
+ ${iconComponent}
87
+ <p>${this.label || this.content}</p>
88
+ `
89
+ }
90
+ }
91
+
92
+ if(this.animation) {
93
+ return `
94
+ <button class="${ButtonStyle.base} ${ButtonStyle.animation[this.animation || 'fill'].base} ${size} ${round}
95
+ ${ButtonStyle.animation[this.animation ?? 'fill'].color[this.animationColor ?? 'indigo']}
96
+
97
+ ">
98
+ ${this.label || this.content}
99
+ </button>
100
+ `
101
+ }
102
+
103
+ const color = ButtonStyle.color?.[this.color ?? 'none']?.[this.variant ?? 'solid'] ?? '';
104
+ return `
105
+ <button class="${ButtonStyle.base} ${color} ${size} ${round}">
106
+ ${content}
107
+ </button>
108
+ `
109
+ }
110
+
111
+ render(): string {
112
+ return this.template();
113
+ }
114
+
115
+ }
116
+
117
+ export {ButtonComponent, ButtonStyle as ButtonConfig}
118
+ export type {ButtonVariants, ButtonRound, ButtonAnimation, ButtonSize, ButtonAnimationColor, IconPosition}
@@ -0,0 +1,66 @@
1
+ import {UIConfig} from "@dota/app.config.ts";
2
+
3
+ const ButtonStyle: Partial<UIConfig> = {
4
+ base: 'inline-flex relative justify-center items-center w-fit transition-all duration-300 active:scale-95 ease-in-out w-full',
5
+
6
+ size: {
7
+ xs: 'px-1 py-0.5 text-xs',
8
+ sm: 'px-1.5 py-1 text-sm',
9
+ md: 'px-2 py-1 text-base',
10
+ lg: 'px-3 py-1.5 text-lg',
11
+ xl: 'px-4 py-0.5 text-lg',
12
+ '2xl': 'px-5 py-0.5 text-xl',
13
+ '3xl': 'px-5 py-0.5 text-2xl',
14
+ },
15
+
16
+ rounded: {
17
+ xs: 'rounded-xs',
18
+ sm: 'rounded-sm',
19
+ md: 'rounded-md',
20
+ lg: 'rounded-lg',
21
+ xl: 'rounded-xl',
22
+ '2xl': 'rounded-2xl',
23
+ '3xl': 'rounded-3xl',
24
+ },
25
+
26
+ color: {
27
+ ...UIConfig.color
28
+ },
29
+
30
+ animation: {
31
+ fill: {
32
+ base: 'buttonFill',
33
+ color: {
34
+ emerald: 'after:bg-emerald-400 before:bg-emerald-500 dark:before:bg-emerald-500 hover:text-white',
35
+ blue: 'after:bg-blue-400 before:bg-blue-500 dark:before:bg-blue-500 hover:text-white',
36
+ sky: 'after:bg-sky-400 before:bg-sky-500 dark:before:bg-sky-500 hover:text-white',
37
+ indigo: 'after:bg-indigo-400 before:bg-indigo-500 dark:before:bg-indigo-500 hover:text-white',
38
+ purple: 'after:bg-purple-400 before:bg-purple-500 dark:before:bg-purple-500 hover:text-white',
39
+ cyan: 'after:bg-cyan-400 before:bg-cyan-500 dark:before:bg-cyan-500 hover:text-white',
40
+ green: 'after:bg-green-400 before:bg-green-500 dark:before:bg-green-500 hover:text-white',
41
+ teal: 'after:bg-teal-400 before:bg-teal-500 dark:before:bg-teal-500 hover:text-white',
42
+ orange: 'after:bg-orange-400 before:bg-orange-500 dark:before:bg-orange-500 hover:text-white',
43
+ yellow: 'after:bg-yellow-400 before:bg-yellow-500 dark:before:bg-yellow-500 hover:text-white',
44
+ rose: 'after:bg-rose-400 before:bg-rose-500 dark:before:bg-rose-500 hover:text-white',
45
+ violet: 'after:bg-violet-400 before:bg-violet-500 dark:before:bg-violet-500 hover:text-white',
46
+ slate: 'after:bg-slate-400 before:bg-slate-500 dark:before:bg-slate-500 hover:text-white',
47
+ gray: 'after:bg-gray-400 before:bg-gray-500 dark:before:bg-gray-500 hover:text-white',
48
+ pink: 'after:bg-pink-400 before:bg-pink-500 dark:before:bg-pink-500 hover:text-white',
49
+ fuchsia: 'after:bg-fuchsia-400 before:bg-fuchsia-500 dark:before:bg-fuchsia-500 hover:text-white',
50
+ },
51
+ },
52
+
53
+ }
54
+
55
+ };
56
+
57
+ type ButtonVariants = keyof ColorVariants
58
+
59
+
60
+ export { ButtonStyle };
61
+ export type { ButtonVariants };
62
+ export type IconPosition = 'leading' | 'forward';
63
+ export type ButtonAnimation = keyof typeof ButtonStyle.animation
64
+ export type ButtonAnimationColor = keyof typeof ButtonStyle.animation.fill.color
65
+ export type ButtonSize = keyof typeof ButtonStyle.size;
66
+ export type ButtonRound = keyof typeof ButtonStyle.rounded;