-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.gts
119 lines (110 loc) · 3.11 KB
/
index.gts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import type { TemplateOnlyComponent } from '@ember/component/template-only';
import { on } from '@ember/modifier';
import type { ComponentLike } from '@glint/template';
import optional from '../../../helpers/optional.ts';
import pick from '../../../helpers/pick.ts';
interface InputSignature {
Args: {
disabled?: boolean;
onBlur?: (ev: Event) => void;
onFocus?: (ev: Event) => void;
onInput?: (val: string) => void;
placeholder?: string;
readonly?: boolean;
required?: boolean;
value?: string;
};
Blocks: Record<string, never>;
Element: HTMLSpanElement;
}
export const Input: TemplateOnlyComponent<InputSignature> = <template>
<input
class='form-control'
placeholder={{@placeholder}}
value={{@value}}
disabled={{@disabled}}
readonly={{@readonly}}
required={{@required}}
{{on 'input' (pick 'target.value' (optional @onInput))}}
{{on 'focus' (optional @onFocus)}}
{{on 'blur' (optional @onBlur)}}
...attributes
/>
<style>
.form-control {
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background-clip: padding-box;
background-color: var(--boxel-light);
color: var(--boxel-text-dark);
display: block;
flex: 1 1 auto;
font: var(--boxel-font-sm);
font-weight: 400;
letter-spacing: var(--boxel-lsp-xs);
margin: 0;
min-width: 0;
padding: var(--boxel-input-group-padding-y)
var(--boxel-input-group-padding-x);
position: relative;
width: 1%;
border: 1px solid var(--boxel-form-control-border-color);
}
.form-control:focus {
outline: none;
}
</style>
</template>;
interface TextareaSignature {
Args: {
placeholder?: string;
value?: string;
};
Blocks: Record<string, never>;
Element: HTMLSpanElement;
}
export const Textarea: TemplateOnlyComponent<TextareaSignature> = <template>
<textarea class='form-control' ...attributes></textarea>
<style>
.form-control {
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background-clip: padding-box;
background-color: var(--boxel-light);
color: var(--boxel-text-dark);
display: block;
flex: 1 1 auto;
font: var(--boxel-font-sm);
font-weight: 400;
letter-spacing: var(--boxel-lsp-xs);
margin: 0;
min-width: 0;
padding: var(--boxel-input-group-padding-y)
var(--boxel-input-group-padding-x);
position: relative;
width: 1%;
}
.form-control {
border: 1px solid var(--boxel-form-control-border-color);
border-radius: var(--boxel-input-group-border-radius);
transition: border-color var(--boxel-transition);
margin: 0;
min-height: var(--boxel-input-group-height);
outline-offset: 0;
}
.form-control:hover,
.form-control:focus {
outline: none;
}
.form-control:disabled {
background-color: var(--boxel-light);
color: rgb(0 0 0 / 50%);
}
</style>
</template>;
export interface ControlsBlockArg {
Input: ComponentLike<InputSignature>;
Textarea: ComponentLike<TextareaSignature>;
}