@frontile/buttons 0.14.1 → 0.16.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.
- package/addon-main.js +4 -0
- package/{components → declarations/components}/button.d.ts +3 -2
- package/declarations/components/button.d.ts.map +1 -0
- package/declarations/template-registry.d.ts +5 -0
- package/declarations/template-registry.d.ts.map +1 -0
- package/dist/_app_/components/button.js +1 -0
- package/dist/components/button.js +43 -0
- package/dist/components/button.js.map +1 -0
- package/dist/template-registry.js +2 -0
- package/dist/template-registry.js.map +1 -0
- package/package.json +78 -58
- package/addon/components/button.hbs +0 -11
- package/addon/components/button.md +0 -106
- package/addon/components/button.ts +0 -73
- package/app/components/button.js +0 -1
- package/config/environment.js +0 -5
- package/index.js +0 -5
- package/tsconfig.json +0 -23
- package/types/dummy/index.d.ts +0 -0
- package/types/global.d.ts +0 -6
package/addon-main.js
ADDED
|
@@ -30,11 +30,12 @@ export interface ButtonSignature {
|
|
|
30
30
|
Blocks: {
|
|
31
31
|
default: [{
|
|
32
32
|
classNames: string;
|
|
33
|
-
}
|
|
33
|
+
}];
|
|
34
34
|
};
|
|
35
|
-
Element: HTMLButtonElement
|
|
35
|
+
Element: HTMLButtonElement;
|
|
36
36
|
}
|
|
37
37
|
export default class Button extends Component<ButtonSignature> {
|
|
38
38
|
get type(): string;
|
|
39
39
|
get classNames(): string;
|
|
40
40
|
}
|
|
41
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/components/button.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,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,QAAQ,CAAC;IAEtD;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;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,CAsBvB;CAsBF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-registry.d.ts","sourceRoot":"","sources":["../src/template-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAE9C,MAAM,CAAC,OAAO,WAAW,QAAQ;IAC/B,MAAM,EAAE,OAAO,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "@frontile/buttons/components/button";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { hash } from '@ember/helper';
|
|
3
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
|
+
import { setComponentTemplate } from '@ember/component';
|
|
5
|
+
|
|
6
|
+
var _class;
|
|
7
|
+
class Button extends Component {
|
|
8
|
+
get type() {
|
|
9
|
+
if (this.args.type) {
|
|
10
|
+
return this.args.type;
|
|
11
|
+
}
|
|
12
|
+
return 'button';
|
|
13
|
+
}
|
|
14
|
+
get classNames() {
|
|
15
|
+
const names1 = [];
|
|
16
|
+
if (this.args.appearance === 'outlined') {
|
|
17
|
+
names1.push('btn-outlined');
|
|
18
|
+
} else if (this.args.appearance === 'minimal') {
|
|
19
|
+
names1.push('btn-minimal');
|
|
20
|
+
} else if (this.args.appearance === 'custom') {
|
|
21
|
+
names1.push('btn-custom');
|
|
22
|
+
} else {
|
|
23
|
+
names1.push('btn');
|
|
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(' ');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_class = Button;
|
|
35
|
+
setComponentTemplate(precompileTemplate("\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 ", {
|
|
36
|
+
scope: () => ({
|
|
37
|
+
hash
|
|
38
|
+
}),
|
|
39
|
+
strictMode: true
|
|
40
|
+
}), _class);
|
|
41
|
+
|
|
42
|
+
export { Button as default };
|
|
43
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +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 names1 = [];\n if (this.args.appearance === 'outlined') {\n names1.push('btn-outlined');\n } else if (this.args.appearance === 'minimal') {\n names1.push('btn-minimal');\n } else if (this.args.appearance === 'custom') {\n names1.push('btn-custom');\n } else {\n names1.push('btn');\n }\n if (this.args.size) {\n names1.push(`${names1[0]}--${this.args.size}`);\n }\n if (this.args.intent) {\n names1.push(`${names1[0]}--${this.args.intent}`);\n }\n return names1.join(' ');\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","names1","appearance","push","size","intent","join","_class","setComponentTemplate","precompileTemplate","scope","hash","strictMode"],"mappings":";;;;;;AAiCe,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,MAAMC,MAAM,GAAG,EAAE,CAAA;AACjB,IAAA,IAAI,IAAI,CAACF,IAAI,CAACG,UAAU,KAAK,UAAU,EAAE;AACrCD,MAAAA,MAAM,CAACE,IAAI,CAAC,cAAc,CAAC,CAAA;KAC9B,MAAM,IAAI,IAAI,CAACJ,IAAI,CAACG,UAAU,KAAK,SAAS,EAAE;AAC3CD,MAAAA,MAAM,CAACE,IAAI,CAAC,aAAa,CAAC,CAAA;KAC7B,MAAM,IAAI,IAAI,CAACJ,IAAI,CAACG,UAAU,KAAK,QAAQ,EAAE;AAC1CD,MAAAA,MAAM,CAACE,IAAI,CAAC,YAAY,CAAC,CAAA;AAC7B,KAAC,MAAM;AACHF,MAAAA,MAAM,CAACE,IAAI,CAAC,KAAK,CAAC,CAAA;AACtB,KAAA;AACA,IAAA,IAAI,IAAI,CAACJ,IAAI,CAACK,IAAI,EAAE;AAChBH,MAAAA,MAAM,CAACE,IAAI,CAAE,CAAA,EAAEF,MAAM,CAAC,CAAC,CAAE,CAAA,EAAA,EAAI,IAAI,CAACF,IAAI,CAACK,IAAK,EAAC,CAAC,CAAA;AAClD,KAAA;AACA,IAAA,IAAI,IAAI,CAACL,IAAI,CAACM,MAAM,EAAE;AAClBJ,MAAAA,MAAM,CAACE,IAAI,CAAE,CAAA,EAAEF,MAAM,CAAC,CAAC,CAAE,CAAA,EAAA,EAAI,IAAI,CAACF,IAAI,CAACM,MAAO,EAAC,CAAC,CAAA;AACpD,KAAA;AACA,IAAA,OAAOJ,MAAM,CAACK,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3B,GAAA;AAiBJ,CAAA;AAACC,MAAA,GA1CoBX,MAAM,CAAA;AA2BnBY,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;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-registry.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontile/buttons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-alpha.0",
|
|
4
4
|
"description": "Component Library for Ember Octane apps: Buttons",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -13,66 +13,57 @@
|
|
|
13
13
|
"doc": "doc",
|
|
14
14
|
"test": "tests"
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"addon-main.js",
|
|
18
|
+
"declarations",
|
|
19
|
+
"dist",
|
|
20
|
+
"tailwind"
|
|
21
|
+
],
|
|
16
22
|
"scripts": {
|
|
17
|
-
"build": "
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
23
|
+
"build": "concurrently -m 1 'npm:build:*'",
|
|
24
|
+
"build:js": "rollup --config",
|
|
25
|
+
"build:types": "glint --declaration",
|
|
26
|
+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
27
|
+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
28
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
29
|
+
"lint:js": "eslint . --cache",
|
|
30
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
31
|
+
"lint:js:fix": "eslint . --fix",
|
|
32
|
+
"lint:types": "glint",
|
|
33
|
+
"start": "concurrently 'npm:start:*'",
|
|
34
|
+
"start:js": "rollup --config --watch --no-watch.clearScreen",
|
|
35
|
+
"start:types": "glint -d --watch",
|
|
36
|
+
"test": "echo 'A v2 addon does not have tests, run tests in test-app'",
|
|
37
|
+
"prepack": "concurrently 'npm:build'"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@babel/runtime": ">= 7",
|
|
41
|
+
"ember-source": "^4.0.0 || ^5.0.0"
|
|
24
42
|
},
|
|
25
43
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"
|
|
28
|
-
"ember-cli-htmlbars": "^6.0.1",
|
|
29
|
-
"ember-cli-typescript": "^5.0.0"
|
|
44
|
+
"@embroider/addon-shim": "^1.8.7",
|
|
45
|
+
"@frontile/tailwindcss-plugin-helpers": "^0.15.0"
|
|
30
46
|
},
|
|
31
47
|
"devDependencies": {
|
|
32
|
-
"@babel/core": "
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"@types/ember__template": "^4.0.0",
|
|
52
|
-
"@types/ember__test": "^4.0.0",
|
|
53
|
-
"@types/ember__test-helpers": "^2.6.1",
|
|
54
|
-
"@types/htmlbars-inline-precompile": "^3.0.0",
|
|
55
|
-
"@types/qunit": "^2.11.3",
|
|
56
|
-
"@types/rsvp": "^4.0.4",
|
|
57
|
-
"broccoli-asset-rev": "^3.0.0",
|
|
58
|
-
"ember-auto-import": "^2.4.1",
|
|
59
|
-
"ember-cli": "^4.2.0",
|
|
60
|
-
"ember-cli-dependency-checker": "^3.2.0",
|
|
61
|
-
"ember-cli-inject-live-reload": "^2.1.0",
|
|
62
|
-
"ember-cli-typescript-blueprints": "^3.0.0",
|
|
63
|
-
"ember-cli-uglify": "^3.0.0",
|
|
64
|
-
"ember-disable-prototype-extensions": "^1.1.3",
|
|
65
|
-
"ember-load-initializers": "^2.1.2",
|
|
66
|
-
"ember-qunit": "^5.1.5",
|
|
67
|
-
"ember-resolver": "^8.0.3",
|
|
68
|
-
"ember-source": "^4.3.0",
|
|
69
|
-
"ember-try": "^2.0.0",
|
|
70
|
-
"loader.js": "^4.7.0",
|
|
71
|
-
"qunit": "^2.18.0",
|
|
72
|
-
"qunit-dom": "^2.0.0",
|
|
73
|
-
"tailwindcss": "^3.0.23",
|
|
74
|
-
"typescript": "^4.6.2",
|
|
75
|
-
"webpack": "^5.70.0"
|
|
48
|
+
"@babel/core": "7.23.6",
|
|
49
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
50
|
+
"@babel/plugin-proposal-decorators": "7.23.6",
|
|
51
|
+
"@babel/plugin-transform-class-static-block": "^7.23.4",
|
|
52
|
+
"@babel/preset-typescript": "7.23.3",
|
|
53
|
+
"@embroider/addon-dev": "4.1.3",
|
|
54
|
+
"@glint/core": "1.2.1",
|
|
55
|
+
"@glint/environment-ember-loose": "1.2.1",
|
|
56
|
+
"@glint/environment-ember-template-imports": "1.2.1",
|
|
57
|
+
"@glint/template": "1.2.1",
|
|
58
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
59
|
+
"@tsconfig/ember": "^3.0.0",
|
|
60
|
+
"babel-plugin-ember-template-compilation": "^2.1.1",
|
|
61
|
+
"concurrently": "^8.2.0",
|
|
62
|
+
"ember-source": "^5.5.0",
|
|
63
|
+
"rollup": "^4.9.1",
|
|
64
|
+
"rollup-plugin-ts": "^3.2.0",
|
|
65
|
+
"tailwindcss": "^3.3.3",
|
|
66
|
+
"typescript": "^5.1.6"
|
|
76
67
|
},
|
|
77
68
|
"engines": {
|
|
78
69
|
"node": "10.* || >= 12"
|
|
@@ -84,7 +75,36 @@
|
|
|
84
75
|
"edition": "octane"
|
|
85
76
|
},
|
|
86
77
|
"ember-addon": {
|
|
87
|
-
"
|
|
78
|
+
"version": 2,
|
|
79
|
+
"type": "addon",
|
|
80
|
+
"main": "addon-main.js",
|
|
81
|
+
"app-js": {
|
|
82
|
+
"./components/button.js": "./dist/_app_/components/button.js"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"exports": {
|
|
86
|
+
".": {
|
|
87
|
+
"types": "./declarations/index.d.ts",
|
|
88
|
+
"default": "./dist/index.js"
|
|
89
|
+
},
|
|
90
|
+
"./*": {
|
|
91
|
+
"types": "./declarations/*.d.ts",
|
|
92
|
+
"default": "./dist/*.js"
|
|
93
|
+
},
|
|
94
|
+
"./addon-main.js": "./addon-main.js",
|
|
95
|
+
"./tailwind": {
|
|
96
|
+
"default": "./tailwind/index.js"
|
|
97
|
+
},
|
|
98
|
+
"./tailwind/*": {
|
|
99
|
+
"default": "./tailwind/*.js"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"typesVersions": {
|
|
103
|
+
"*": {
|
|
104
|
+
"*": [
|
|
105
|
+
"declarations/*"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
88
108
|
},
|
|
89
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "c1f2fb51b859e18d1bcb94090055ad9c1128d4d3"
|
|
90
110
|
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# Button
|
|
2
|
-
|
|
3
|
-
The Button component can be used to trigger an action, such as submitting a form, opening a modal, and more.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```hbs preview-template
|
|
8
|
-
<Button>Button</Button>
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Button Appearances
|
|
12
|
-
|
|
13
|
-
```hbs preview-template
|
|
14
|
-
<div>
|
|
15
|
-
<Button>Default</Button>
|
|
16
|
-
<Button @appearance="outlined">Outlined</Button>
|
|
17
|
-
<Button @appearance="minimal">Minimal</Button>
|
|
18
|
-
<Button @appearance="custom">Custom</Button>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="mt-4">
|
|
21
|
-
<Button disabled>Default</Button>
|
|
22
|
-
<Button @appearance="outlined" disabled>Outlined</Button>
|
|
23
|
-
<Button @appearance="minimal" disabled>Minimal</Button>
|
|
24
|
-
<Button @appearance="custom" disabled>Custom</Button>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The `custom` appearance is available for the cases where you might want to fully customize the appearance of the button.
|
|
30
|
-
The default styles are mainly structural. Intent colors are applied as `color`.
|
|
31
|
-
|
|
32
|
-
## Button Intents
|
|
33
|
-
|
|
34
|
-
```hbs preview-template
|
|
35
|
-
<div>
|
|
36
|
-
<Button @intent="primary">Button</Button>
|
|
37
|
-
<Button @intent="success">Button</Button>
|
|
38
|
-
<Button @intent="warning">Button</Button>
|
|
39
|
-
<Button @intent="danger">Button</Button>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="mt-4">
|
|
42
|
-
<Button @intent="primary" disabled>Button</Button>
|
|
43
|
-
<Button @intent="success" disabled>Button</Button>
|
|
44
|
-
<Button @intent="warning" disabled>Button</Button>
|
|
45
|
-
<Button @intent="danger" disabled>Button</Button>
|
|
46
|
-
</div>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Button Sizes
|
|
50
|
-
|
|
51
|
-
```hbs preview-template
|
|
52
|
-
<Button @size="xs">Button</Button>
|
|
53
|
-
<Button @size="sm">Button</Button>
|
|
54
|
-
<Button>Button</Button>
|
|
55
|
-
<Button @size="lg">Button</Button>
|
|
56
|
-
<Button @size="xl">Button</Button>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Renderless Button
|
|
60
|
-
|
|
61
|
-
Sometimes a button element is not ideal for a given case, but the same styles are still desired.
|
|
62
|
-
Frontile provides the option to disable rendering the `button` element, but instead it yields back an object with
|
|
63
|
-
the class names it would use.
|
|
64
|
-
|
|
65
|
-
```hbs preview-template
|
|
66
|
-
<Button @isRenderless={{true}} as |btn|>
|
|
67
|
-
<a href="javascript:void(0)" class={{btn.classNames}}>My Link</a>
|
|
68
|
-
</Button>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Composition
|
|
72
|
-
|
|
73
|
-
You can compose appearance with intents and more to create the button that best fits your needs.
|
|
74
|
-
|
|
75
|
-
```hbs preview-template
|
|
76
|
-
<Button @appearance="outlined" @intent="primary">Button</Button>
|
|
77
|
-
<Button @appearance="minimal" @intent="warning">Button</Button>
|
|
78
|
-
<Button @size="xs" @intent="danger">Button</Button>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
You can also use TailwindCSS classes to customize even further.
|
|
82
|
-
|
|
83
|
-
```hbs preview-template
|
|
84
|
-
<Button
|
|
85
|
-
@appearance="outlined"
|
|
86
|
-
@intent="primary"
|
|
87
|
-
class="px-20 py-2 italic"
|
|
88
|
-
>
|
|
89
|
-
Button
|
|
90
|
-
</Button>
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Here is another example using TailwindCSS classes with the `custom` appearance.
|
|
94
|
-
|
|
95
|
-
```hbs preview-template
|
|
96
|
-
<Button
|
|
97
|
-
@appearance="custom"
|
|
98
|
-
class="bg-teal-100 hover:bg-teal-200 hover:text-teal-600 border-teal-600 rounded-none border-dashed"
|
|
99
|
-
>
|
|
100
|
-
Button
|
|
101
|
-
</Button>
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## API
|
|
105
|
-
|
|
106
|
-
<ArgsTable @of="Button" />
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import Component from '@glimmer/component';
|
|
2
|
-
|
|
3
|
-
export interface ButtonArgs {
|
|
4
|
-
/**
|
|
5
|
-
* The HTML type of the button
|
|
6
|
-
*
|
|
7
|
-
* @defaultValue 'button'
|
|
8
|
-
*/
|
|
9
|
-
type?: 'button' | 'submit' | 'reset';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The button appearance
|
|
13
|
-
*
|
|
14
|
-
* @defaultValue 'default'
|
|
15
|
-
*/
|
|
16
|
-
appearance?: 'default' | 'outlined' | 'minimal' | 'custom';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The intent of the button
|
|
20
|
-
*/
|
|
21
|
-
intent?: 'primary' | 'success' | 'warning' | 'danger';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The size of the button
|
|
25
|
-
*/
|
|
26
|
-
size?: 'xs' | 'sm' | 'lg' | 'xl';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Disable rendering the button element. It yields an object with classNames instead.
|
|
30
|
-
*/
|
|
31
|
-
isRenderless?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface ButtonSignature {
|
|
35
|
-
Args: ButtonArgs;
|
|
36
|
-
Blocks: {
|
|
37
|
-
default: [{ classNames: string } | null];
|
|
38
|
-
};
|
|
39
|
-
Element: HTMLButtonElement | null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default class Button extends Component<ButtonSignature> {
|
|
43
|
-
get type(): string {
|
|
44
|
-
if (this.args.type) {
|
|
45
|
-
return this.args.type;
|
|
46
|
-
}
|
|
47
|
-
return 'button';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get classNames(): string {
|
|
51
|
-
const names = [];
|
|
52
|
-
|
|
53
|
-
if (this.args.appearance === 'outlined') {
|
|
54
|
-
names.push('btn-outlined');
|
|
55
|
-
} else if (this.args.appearance === 'minimal') {
|
|
56
|
-
names.push('btn-minimal');
|
|
57
|
-
} else if (this.args.appearance === 'custom') {
|
|
58
|
-
names.push('btn-custom');
|
|
59
|
-
} else {
|
|
60
|
-
names.push('btn');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (this.args.size) {
|
|
64
|
-
names.push(`${names[0]}--${this.args.size}`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (this.args.intent) {
|
|
68
|
-
names.push(`${names[0]}--${this.args.intent}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return names.join(' ');
|
|
72
|
-
}
|
|
73
|
-
}
|
package/app/components/button.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@frontile/buttons/components/button';
|
package/config/environment.js
DELETED
package/index.js
DELETED
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"paths": {
|
|
6
|
-
"dummy/tests/*": ["tests/*"],
|
|
7
|
-
"dummy/*": ["tests/dummy/app/*", "app/*"],
|
|
8
|
-
"@frontile/buttons": ["addon"],
|
|
9
|
-
"@frontile/buttons/*": ["addon/*"],
|
|
10
|
-
"@frontile/buttons/test-support": ["addon-test-support"],
|
|
11
|
-
"@frontile/buttons/test-support/*": ["addon-test-support/*"],
|
|
12
|
-
"*": ["types/*"]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"app/**/*",
|
|
17
|
-
"addon/**/*",
|
|
18
|
-
"tests/**/*",
|
|
19
|
-
"types/**/*",
|
|
20
|
-
"test-support/**/*",
|
|
21
|
-
"addon-test-support/**/*"
|
|
22
|
-
]
|
|
23
|
-
}
|
package/types/dummy/index.d.ts
DELETED
|
File without changes
|