Skip to content

Commit e729dea

Browse files
committed
feat(chip): add recipe and variables
1 parent 6ae701e commit e729dea

File tree

11 files changed

+945
-79
lines changed

11 files changed

+945
-79
lines changed

core/src/components.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ export namespace Components {
872872
*/
873873
"disabled": boolean;
874874
/**
875-
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Only applies to the `ionic` theme.
875+
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Defaults to `"subtle"`.
876876
* @default 'subtle'
877877
*/
878878
"hue"?: 'bold' | 'subtle';
@@ -891,8 +891,9 @@ export namespace Components {
891891
"shape"?: 'soft' | 'round' | 'rectangular';
892892
/**
893893
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"` for the ionic theme, and undefined for all other themes.
894+
* @default 'medium'
894895
*/
895-
"size"?: 'small' | 'large';
896+
"size"?: 'small' | 'medium' | 'large';
896897
/**
897898
* The theme determines the visual appearance of the component.
898899
*/
@@ -6842,7 +6843,7 @@ declare namespace LocalJSX {
68426843
*/
68436844
"disabled"?: boolean;
68446845
/**
6845-
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Only applies to the `ionic` theme.
6846+
* Set to `"bold"` for a chip with vibrant, bold colors or to `"subtle"` for a chip with muted, subtle colors. Defaults to `"subtle"`.
68466847
* @default 'subtle'
68476848
*/
68486849
"hue"?: 'bold' | 'subtle';
@@ -6861,8 +6862,9 @@ declare namespace LocalJSX {
68616862
"shape"?: 'soft' | 'round' | 'rectangular';
68626863
/**
68636864
* Set to `"small"` for a chip with less height and padding. Defaults to `"large"` for the ionic theme, and undefined for all other themes.
6865+
* @default 'medium'
68646866
*/
6865-
"size"?: 'small' | 'large';
6867+
"size"?: 'small' | 'medium' | 'large';
68666868
/**
68676869
* The theme determines the visual appearance of the component.
68686870
*/
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
@use "../../themes/mixins" as mixins;
2+
@use "../../themes/functions.color" as colors;
3+
@use "./chip.base.vars.scss" as vars;
4+
5+
// Chip: Common Styles
6+
// --------------------------------------------------
7+
8+
:host {
9+
/**
10+
* @prop --background: Background of the chip
11+
* @prop --border-radius: Border radius of the chip
12+
* @prop --color: Color of the chip
13+
* @prop --focus-ring-color: Color of the focus ring
14+
* @prop --focus-ring-width: Width of the focus ring
15+
*/
16+
--focus-ring-color: #{vars.$chip-focus-ring-color};
17+
--focus-ring-width: #{vars.$chip-focus-ring-width};
18+
19+
@include mixins.font-smoothing();
20+
@include mixins.border-radius(var(--border-radius));
21+
@include mixins.margin(vars.$chip-margin);
22+
@include mixins.padding(vars.$chip-padding-vertical, vars.$chip-padding-horizontal);
23+
24+
display: inline-flex;
25+
position: relative;
26+
27+
align-items: center;
28+
justify-content: center;
29+
30+
background: var(--background);
31+
color: var(--color);
32+
33+
line-height: vars.$chip-line-height;
34+
35+
cursor: pointer;
36+
overflow: hidden;
37+
vertical-align: middle;
38+
box-sizing: border-box;
39+
40+
gap: vars.$chip-gap;
41+
}
42+
43+
// Chip Sizes
44+
// ---------------------------------------------
45+
46+
:host(.chip-small) {
47+
min-height: vars.$chip-size-small-height;
48+
49+
font-size: vars.$chip-size-small-font-size;
50+
}
51+
52+
:host(.chip-medium) {
53+
min-height: vars.$chip-size-medium-height;
54+
55+
font-size: vars.$chip-size-medium-font-size;
56+
}
57+
58+
:host(.chip-large) {
59+
min-height: vars.$chip-size-large-height;
60+
61+
font-size: vars.$chip-size-large-font-size;
62+
}
63+
64+
// Chip Shapes
65+
// ---------------------------------------------
66+
67+
:host(.chip-soft) {
68+
--border-radius: #{vars.$chip-border-radius-soft};
69+
}
70+
71+
:host(.chip-round) {
72+
--border-radius: #{vars.$chip-border-radius-round};
73+
}
74+
75+
:host(.chip-rectangular) {
76+
--border-radius: #{vars.$chip-border-radius-rectangular};
77+
}
78+
79+
// Chip Hues
80+
// ---------------------------------------------
81+
82+
// Bold
83+
:host(.chip-bold) {
84+
--background: #{vars.$chip-hue-bold-bg};
85+
--color: #{vars.$chip-hue-bold-color};
86+
}
87+
88+
:host(.chip-bold.chip-outline) {
89+
border-color: #{vars.$chip-hue-bold-outline-border-color};
90+
}
91+
92+
// Subtle
93+
:host(.chip-subtle) {
94+
--background: #{vars.$chip-hue-subtle-bg};
95+
--color: #{vars.$chip-hue-subtle-color};
96+
}
97+
98+
:host(.chip-subtle.chip-outline) {
99+
border-color: #{vars.$chip-hue-subtle-outline-border-color};
100+
}
101+
102+
// Chip Colors
103+
// ---------------------------------------------
104+
105+
// Bold
106+
:host(.ion-color.chip-bold) {
107+
background: colors.current-color(base, vars.$chip-hue-bold-semantic-bg-alpha);
108+
color: vars.$chip-hue-bold-semantic-color;
109+
}
110+
111+
:host(.ion-color.chip-bold.chip-outline) {
112+
border-color: vars.$chip-hue-bold-semantic-outline-border-color;
113+
}
114+
115+
// Subtle
116+
:host(.ion-color.chip-subtle) {
117+
background: colors.current-color(base, $subtle: true);
118+
color: colors.current-color(contrast, $subtle: true);
119+
}
120+
121+
:host(.ion-color.chip-subtle.chip-outline) {
122+
border-color: colors.current-color(shade, $subtle: true);
123+
}
124+
125+
// Outline Chip
126+
// ---------------------------------------------
127+
128+
:host(.chip-outline) {
129+
border-width: vars.$chip-outline-border-width;
130+
border-style: solid;
131+
}
132+
133+
:host(.chip-outline),
134+
:host(.chip-outline.ion-color) {
135+
background: vars.$chip-outline-bg;
136+
}
137+
138+
// Chip States
139+
// ---------------------------------------------
140+
141+
// Disabled
142+
:host(.chip-disabled) {
143+
cursor: default;
144+
opacity: vars.$chip-state-disabled-opacity;
145+
pointer-events: none;
146+
}
147+
148+
// Focus
149+
:host(.ion-focused) {
150+
--background: #{vars.$chip-focus-bg};
151+
152+
@include mixins.focused-state(var(--focus-ring-width), $color: var(--focus-ring-color));
153+
}
154+
155+
:host(.ion-focused.ion-color) {
156+
background: vars.$chip-focus-semantic-bg;
157+
}
158+
159+
:host(.ion-focused.chip-outline:not(.ion-color)) {
160+
background: vars.$chip-outline-focus-bg;
161+
}
162+
163+
// Activated
164+
:host(.ion-activated) {
165+
--background: #{vars.$chip-activated-bg};
166+
}
167+
168+
:host(.ion-activated.ion-color) {
169+
background: vars.$chip-activated-semantic-bg;
170+
}
171+
172+
// Hover
173+
@media (any-hover: hover) {
174+
:host(:hover) {
175+
--background: #{vars.$chip-hover-bg};
176+
}
177+
178+
:host(.ion-color:hover) {
179+
background: vars.$chip-hover-semantic-bg;
180+
}
181+
182+
:host(.chip-outline:not(.ion-color):hover) {
183+
background: vars.$chip-outline-hover-bg;
184+
}
185+
}
186+
187+
// Chip Slotted Elements
188+
// ---------------------------------------------
189+
190+
// Icon
191+
::slotted(ion-icon) {
192+
font-size: vars.$chip-icon-size;
193+
}
194+
195+
:host(:not(.ion-color)) ::slotted(ion-icon) {
196+
color: vars.$chip-icon-color;
197+
}
198+
199+
::slotted(ion-icon:first-child) {
200+
@include mixins.margin(vars.$chip-icon-first-child-margin, vars.$chip-icon-first-child-margin-end, $start: vars.$chip-icon-first-child-margin);
201+
}
202+
203+
::slotted(ion-icon:last-child) {
204+
@include mixins.margin(vars.$chip-icon-last-child-margin, $start: vars.$chip-icon-last-child-margin-start);
205+
}
206+
207+
// Avatar
208+
::slotted(ion-avatar) {
209+
flex-shrink: 0;
210+
211+
width: vars.$chip-avatar-size;
212+
height: vars.$chip-avatar-size;
213+
}
214+
215+
::slotted(ion-avatar:first-child) {
216+
@include mixins.margin(vars.$chip-avatar-first-child-margin-vertical, $end: vars.$chip-avatar-first-child-margin-end, $start: vars.$chip-avatar-first-child-margin-start);
217+
}
218+
219+
::slotted(ion-avatar:last-child) {
220+
@include mixins.margin(vars.$chip-avatar-last-child-margin-vertical, $end: vars.$chip-avatar-last-child-margin-end, $start: vars.$chip-avatar-last-child-margin-start);
221+
}
222+

0 commit comments

Comments
 (0)