@frontile/buttons 0.16.2 → 0.17.0-alpha.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.
|
@@ -15,7 +15,7 @@ export interface ButtonArgs {
|
|
|
15
15
|
/**
|
|
16
16
|
* The intent of the button
|
|
17
17
|
*/
|
|
18
|
-
intent?: 'primary' | 'success' | 'warning' | 'danger';
|
|
18
|
+
intent?: 'default' | 'primary' | 'success' | 'warning' | 'danger';
|
|
19
19
|
/**
|
|
20
20
|
* The size of the button
|
|
21
21
|
*/
|
|
@@ -24,6 +24,10 @@ export interface ButtonArgs {
|
|
|
24
24
|
* Disable rendering the button element. It yields an object with classNames instead.
|
|
25
25
|
*/
|
|
26
26
|
isRenderless?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Custom class name, it will override the default ones using Tailwind Merge library.
|
|
29
|
+
*/
|
|
30
|
+
class?: string;
|
|
27
31
|
}
|
|
28
32
|
export interface ButtonSignature {
|
|
29
33
|
Args: ButtonArgs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/components/button.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/components/button.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAI3C,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IAErC;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAElE;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE;QACN,OAAO,EAAE,CAAC;YAAE,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnC,CAAC;IACF,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,SAAS,CAAC,eAAe,CAAC;IAC5D,IAAI,IAAI,IAAI,MAAM,CAKjB;IAED,IAAI,UAAU,IAAI,MAAM,CASvB;CAsBF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { hash } from '@ember/helper';
|
|
3
|
+
import { useStyles } from '@frontile/theme';
|
|
3
4
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
5
|
import { setComponentTemplate } from '@ember/component';
|
|
5
6
|
|
|
@@ -12,23 +13,15 @@ class Button extends Component {
|
|
|
12
13
|
return 'button';
|
|
13
14
|
}
|
|
14
15
|
get classNames() {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
if (this.args.size) {
|
|
26
|
-
names1.push(`${names1[0]}--${this.args.size}`);
|
|
27
|
-
}
|
|
28
|
-
if (this.args.intent) {
|
|
29
|
-
names1.push(`${names1[0]}--${this.args.intent}`);
|
|
30
|
-
}
|
|
31
|
-
return names1.join(' ');
|
|
16
|
+
const {
|
|
17
|
+
button: button1
|
|
18
|
+
} = useStyles();
|
|
19
|
+
return button1({
|
|
20
|
+
intent: this.args.intent || 'default',
|
|
21
|
+
size: this.args.size,
|
|
22
|
+
appearance: this.args.appearance || 'default',
|
|
23
|
+
class: this.args.class
|
|
24
|
+
});
|
|
32
25
|
}
|
|
33
26
|
}
|
|
34
27
|
_class = Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sources":["../../src/components/button.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nexport interface ButtonArgs {\n /**\n * The HTML type of the button\n *\n * @defaultValue 'button'\n */ type?: 'button' | 'submit' | 'reset';\n /**\n * The button appearance\n *\n * @defaultValue 'default'\n */ appearance?: 'default' | 'outlined' | 'minimal' | 'custom';\n /**\n * The intent of the button\n */ intent?: 'primary' | 'success' | 'warning' | 'danger';\n /**\n * The size of the button\n */ size?: 'xs' | 'sm' | 'lg' | 'xl';\n /**\n * Disable rendering the button element. It yields an object with classNames instead.\n */ isRenderless?: boolean;\n}\nexport interface ButtonSignature {\n Args: ButtonArgs;\n Blocks: {\n default: [{\n classNames: string;\n }];\n };\n Element: HTMLButtonElement;\n}\nexport default class Button extends Component<ButtonSignature> {\n get type(): string {\n if (this.args.type) {\n return this.args.type;\n }\n return 'button';\n }\n get classNames(): string {\n const
|
|
1
|
+
{"version":3,"file":"button.js","sources":["../../src/components/button.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { useStyles } from '@frontile/theme';\nexport interface ButtonArgs {\n /**\n * The HTML type of the button\n *\n * @defaultValue 'button'\n */ type?: 'button' | 'submit' | 'reset';\n /**\n * The button appearance\n *\n * @defaultValue 'default'\n */ appearance?: 'default' | 'outlined' | 'minimal' | 'custom';\n /**\n * The intent of the button\n */ intent?: 'default' | 'primary' | 'success' | 'warning' | 'danger';\n /**\n * The size of the button\n */ size?: 'xs' | 'sm' | 'lg' | 'xl';\n /**\n * Disable rendering the button element. It yields an object with classNames instead.\n */ isRenderless?: boolean;\n /**\n * Custom class name, it will override the default ones using Tailwind Merge library.\n */ class?: string;\n}\nexport interface ButtonSignature {\n Args: ButtonArgs;\n Blocks: {\n default: [{\n classNames: string;\n }];\n };\n Element: HTMLButtonElement;\n}\nexport default class Button extends Component<ButtonSignature> {\n get type(): string {\n if (this.args.type) {\n return this.args.type;\n }\n return 'button';\n }\n get classNames(): string {\n const { button: button1 } = useStyles();\n return button1({\n intent: this.args.intent || 'default',\n size: this.args.size,\n appearance: this.args.appearance || 'default',\n class: this.args.class\n });\n }\n static{\n template(`\n {{#if @isRenderless}}\n {{yield (hash classNames=this.classNames)}}\n {{else}}\n <button type={{this.type}} class={{this.classNames}} ...attributes>\n {{yield (hash classNames=this.classNames)}}\n </button>\n {{/if}}\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["Button","Component","type","args","classNames","button","button1","useStyles","intent","size","appearance","class","_class","setComponentTemplate","precompileTemplate","scope","hash","strictMode"],"mappings":";;;;;;;AAqCe,MAAMA,MAAM,SAASC,SAAS,CAAkB;EAC3D,IAAIC,IAAIA,GAAW;AACf,IAAA,IAAI,IAAI,CAACC,IAAI,CAACD,IAAI,EAAE;AAChB,MAAA,OAAO,IAAI,CAACC,IAAI,CAACD,IAAI,CAAA;AACzB,KAAA;AACA,IAAA,OAAO,QAAQ,CAAA;AACnB,GAAA;EACA,IAAIE,UAAUA,GAAW;IACrB,MAAM;AAAEC,MAAAA,MAAM,EAAEC,OAAAA;KAAS,GAAGC,SAAS,EAAE,CAAA;AACvC,IAAA,OAAOD,OAAO,CAAC;AACXE,MAAAA,MAAM,EAAE,IAAI,CAACL,IAAI,CAACK,MAAM,IAAI,SAAS;AACrCC,MAAAA,IAAI,EAAE,IAAI,CAACN,IAAI,CAACM,IAAI;AACpBC,MAAAA,UAAU,EAAE,IAAI,CAACP,IAAI,CAACO,UAAU,IAAI,SAAS;AAC7CC,MAAAA,KAAK,EAAE,IAAI,CAACR,IAAI,CAACQ,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAiBJ,CAAA;AAACC,MAAA,GAhCoBZ,MAAM,CAAA;AAiBnBa,oBAAA,CAAAC,kBAAA,CAQH,gQAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA,IAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAL,MAAA,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontile/buttons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0-alpha.0",
|
|
4
4
|
"description": "Component Library for Ember Octane apps: Buttons",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"addon-main.js",
|
|
18
18
|
"declarations",
|
|
19
|
-
"dist"
|
|
20
|
-
"tailwind"
|
|
19
|
+
"dist"
|
|
21
20
|
],
|
|
22
21
|
"scripts": {
|
|
23
22
|
"build": "concurrently -m 1 'npm:build:*'",
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
43
|
"@embroider/addon-shim": "^1.8.7",
|
|
45
|
-
"@frontile/
|
|
44
|
+
"@frontile/theme": "^0.17.0-alpha.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@babel/core": "7.23.6",
|
|
@@ -93,13 +92,7 @@
|
|
|
93
92
|
"types": "./declarations/*.d.ts",
|
|
94
93
|
"default": "./dist/*.js"
|
|
95
94
|
},
|
|
96
|
-
"./addon-main.js": "./addon-main.js"
|
|
97
|
-
"./tailwind": {
|
|
98
|
-
"default": "./tailwind/index.js"
|
|
99
|
-
},
|
|
100
|
-
"./tailwind/*": {
|
|
101
|
-
"default": "./tailwind/*.js"
|
|
102
|
-
}
|
|
95
|
+
"./addon-main.js": "./addon-main.js"
|
|
103
96
|
},
|
|
104
97
|
"typesVersions": {
|
|
105
98
|
"*": {
|
|
@@ -108,5 +101,5 @@
|
|
|
108
101
|
]
|
|
109
102
|
}
|
|
110
103
|
},
|
|
111
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "64b5faa1b14763b32cf93e10a5035c0bd06b47d3"
|
|
112
105
|
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
const defaultTheme = require('tailwindcss/resolveConfig')(
|
|
2
|
-
require('tailwindcss/defaultConfig')
|
|
3
|
-
).theme;
|
|
4
|
-
|
|
5
|
-
const defaultConfig = {
|
|
6
|
-
borderRadius: defaultTheme.borderRadius.DEFAULT,
|
|
7
|
-
focusBoxShadow: '0 0 0 3px rgba(59, 130, 246, 0.45)',
|
|
8
|
-
default: {
|
|
9
|
-
contrastColor: defaultTheme.colors.white,
|
|
10
|
-
color: defaultTheme.colors.gray[700],
|
|
11
|
-
hoverColor: defaultTheme.colors.gray[800],
|
|
12
|
-
activeColor: defaultTheme.colors.gray[900]
|
|
13
|
-
},
|
|
14
|
-
minimal: {
|
|
15
|
-
hoverBackgroundColor: defaultTheme.colors.gray[200],
|
|
16
|
-
activeBackgroundColor: defaultTheme.colors.gray[300]
|
|
17
|
-
},
|
|
18
|
-
primary: {
|
|
19
|
-
contrastColor: defaultTheme.colors.white,
|
|
20
|
-
color: defaultTheme.colors.blue[700],
|
|
21
|
-
hoverColor: defaultTheme.colors.blue[800],
|
|
22
|
-
activeColor: defaultTheme.colors.blue[900]
|
|
23
|
-
},
|
|
24
|
-
success: {
|
|
25
|
-
contrastColor: defaultTheme.colors.white,
|
|
26
|
-
color: defaultTheme.colors.green[600],
|
|
27
|
-
hoverColor: defaultTheme.colors.green[700],
|
|
28
|
-
activeColor: defaultTheme.colors.green[800]
|
|
29
|
-
},
|
|
30
|
-
warning: {
|
|
31
|
-
contrastColor: defaultTheme.colors.white,
|
|
32
|
-
color: defaultTheme.colors.yellow[600],
|
|
33
|
-
hoverColor: defaultTheme.colors.yellow[700],
|
|
34
|
-
activeColor: defaultTheme.colors.yellow[800]
|
|
35
|
-
},
|
|
36
|
-
danger: {
|
|
37
|
-
contrastColor: defaultTheme.colors.white,
|
|
38
|
-
color: defaultTheme.colors.red[600],
|
|
39
|
-
hoverColor: defaultTheme.colors.red[700],
|
|
40
|
-
activeColor: defaultTheme.colors.red[800]
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function defaultOptions({ config }) {
|
|
45
|
-
const hover = '&:not([disabled]):hover';
|
|
46
|
-
const active = '&:not([disabled]):active,&.is-active';
|
|
47
|
-
|
|
48
|
-
function generateIntents(options) {
|
|
49
|
-
return {
|
|
50
|
-
default: {
|
|
51
|
-
color: options.contrastColor,
|
|
52
|
-
backgroundColor: options.color,
|
|
53
|
-
[hover]: {
|
|
54
|
-
backgroundColor: options.hoverColor
|
|
55
|
-
},
|
|
56
|
-
[active]: {
|
|
57
|
-
backgroundColor: options.activeColor
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
outlined: {
|
|
61
|
-
color: options.color,
|
|
62
|
-
borderColor: options.color,
|
|
63
|
-
[hover]: {
|
|
64
|
-
color: options.contrastColor,
|
|
65
|
-
backgroundColor: options.color
|
|
66
|
-
},
|
|
67
|
-
[active]: {
|
|
68
|
-
color: options.contrastColor,
|
|
69
|
-
backgroundColor: options.hoverColor
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
minimal: {
|
|
73
|
-
color: options.color
|
|
74
|
-
},
|
|
75
|
-
custom: {
|
|
76
|
-
color: options.color
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function generateVariants(type) {
|
|
82
|
-
const intends = {
|
|
83
|
-
default: generateIntents(config.default),
|
|
84
|
-
primary: generateIntents(config.primary),
|
|
85
|
-
success: generateIntents(config.success),
|
|
86
|
-
warning: generateIntents(config.warning),
|
|
87
|
-
danger: generateIntents(config.danger)
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
...Object.keys(intends).reduce((obj, key) => {
|
|
92
|
-
obj[key] = intends[key][type];
|
|
93
|
-
return obj;
|
|
94
|
-
}, {})
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
'default, outlined, minimal, custom': {
|
|
100
|
-
baseStyle: {
|
|
101
|
-
lineHeight: defaultTheme.lineHeight.tight,
|
|
102
|
-
display: 'inline-block',
|
|
103
|
-
fontWeight: defaultTheme.fontWeight.semibold,
|
|
104
|
-
paddingTop: defaultTheme.spacing[3],
|
|
105
|
-
paddingRight: defaultTheme.spacing[4],
|
|
106
|
-
paddingBottom: defaultTheme.spacing[3],
|
|
107
|
-
paddingLeft: defaultTheme.spacing[4],
|
|
108
|
-
borderRadius: config.borderRadius,
|
|
109
|
-
borderWidth: defaultTheme.borderWidth.DEFAULT,
|
|
110
|
-
borderColor: defaultTheme.colors.transparent,
|
|
111
|
-
'&.focus-visible:focus': {
|
|
112
|
-
outline: 'none',
|
|
113
|
-
boxShadow: config.focusBoxShadow
|
|
114
|
-
},
|
|
115
|
-
'&[disabled]': {
|
|
116
|
-
opacity: '0.4',
|
|
117
|
-
cursor: defaultTheme.cursor['not-allowed']
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
variants: {
|
|
121
|
-
xs: {
|
|
122
|
-
fontSize: defaultTheme.fontSize.sm[0],
|
|
123
|
-
paddingTop: defaultTheme.spacing[1],
|
|
124
|
-
paddingRight: defaultTheme.spacing[2],
|
|
125
|
-
paddingBottom: defaultTheme.spacing[1],
|
|
126
|
-
paddingLeft: defaultTheme.spacing[2]
|
|
127
|
-
},
|
|
128
|
-
sm: {
|
|
129
|
-
paddingTop: defaultTheme.spacing[2],
|
|
130
|
-
paddingRight: defaultTheme.spacing[3],
|
|
131
|
-
paddingBottom: defaultTheme.spacing[2],
|
|
132
|
-
paddingLeft: defaultTheme.spacing[3]
|
|
133
|
-
},
|
|
134
|
-
lg: {
|
|
135
|
-
paddingTop: defaultTheme.spacing[4],
|
|
136
|
-
paddingRight: defaultTheme.spacing[4],
|
|
137
|
-
paddingBottom: defaultTheme.spacing[4],
|
|
138
|
-
paddingLeft: defaultTheme.spacing[4]
|
|
139
|
-
},
|
|
140
|
-
xl: {
|
|
141
|
-
fontSize: defaultTheme.fontSize.xl[0],
|
|
142
|
-
paddingTop: defaultTheme.spacing[5],
|
|
143
|
-
paddingRight: defaultTheme.spacing[6],
|
|
144
|
-
paddingBottom: defaultTheme.spacing[5],
|
|
145
|
-
paddingLeft: defaultTheme.spacing[6]
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
default: {
|
|
150
|
-
baseStyle: {
|
|
151
|
-
borderColor: defaultTheme.colors.transparent
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
variants: generateVariants('default')
|
|
155
|
-
},
|
|
156
|
-
outlined: {
|
|
157
|
-
baseStyle: {
|
|
158
|
-
backgroundColor: defaultTheme.colors.transparent
|
|
159
|
-
},
|
|
160
|
-
variants: generateVariants('outlined')
|
|
161
|
-
},
|
|
162
|
-
minimal: {
|
|
163
|
-
baseStyle: {
|
|
164
|
-
backgroundColor: defaultTheme.colors.transparent,
|
|
165
|
-
borderColor: defaultTheme.colors.transparent,
|
|
166
|
-
[hover]: {
|
|
167
|
-
backgroundColor: config.minimal.hoverBackgroundColor
|
|
168
|
-
},
|
|
169
|
-
[active]: {
|
|
170
|
-
backgroundColor: config.minimal.activeBackgroundColor
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
variants: generateVariants('minimal')
|
|
175
|
-
},
|
|
176
|
-
custom: {
|
|
177
|
-
baseStyle: {
|
|
178
|
-
'&[disabled]': {
|
|
179
|
-
opacity: null
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
variants: generateVariants('custom')
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
module.exports = {
|
|
189
|
-
defaultConfig,
|
|
190
|
-
defaultOptions
|
|
191
|
-
};
|
package/tailwind/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const plugin = require('tailwindcss/plugin');
|
|
2
|
-
const {
|
|
3
|
-
resolveComponents,
|
|
4
|
-
addSinglePartComponent
|
|
5
|
-
} = require('@frontile/tailwindcss-plugin-helpers');
|
|
6
|
-
|
|
7
|
-
module.exports = plugin.withOptions(function () {
|
|
8
|
-
return function ({ addComponents, theme }) {
|
|
9
|
-
const { components } = resolveComponents(
|
|
10
|
-
theme('frontile.buttons') || {},
|
|
11
|
-
require('./default-options')
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
addSinglePartComponent(addComponents, '.btn', components.default);
|
|
15
|
-
addSinglePartComponent(addComponents, '.btn-outlined', components.outlined);
|
|
16
|
-
addSinglePartComponent(addComponents, '.btn-minimal', components.minimal);
|
|
17
|
-
addSinglePartComponent(addComponents, '.btn-custom', components.custom);
|
|
18
|
-
};
|
|
19
|
-
});
|