Skip to content

Commit 098cba4

Browse files
committed
feat(chip): adding ionic theme
1 parent 7040091 commit 098cba4

File tree

12 files changed

+469
-62
lines changed

12 files changed

+469
-62
lines changed

core/src/components.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,10 @@ export namespace Components {
890890
*/
891891
"shape"?: 'soft' | 'round' | 'rectangular';
892892
/**
893-
* Set to `"small"` for a chip with less height and padding. Defaults to `"medium"`.
894-
* @default 'medium'
893+
* Set to `"small"` for a chip with less height and padding. Defaults to `"small"`.
894+
* @default 'large'
895895
*/
896-
"size"?: 'small' | 'medium' | 'large';
896+
"size"?: 'small' | 'large';
897897
/**
898898
* The theme determines the visual appearance of the component.
899899
*/
@@ -6861,10 +6861,10 @@ declare namespace LocalJSX {
68616861
*/
68626862
"shape"?: 'soft' | 'round' | 'rectangular';
68636863
/**
6864-
* Set to `"small"` for a chip with less height and padding. Defaults to `"medium"`.
6865-
* @default 'medium'
6864+
* Set to `"small"` for a chip with less height and padding. Defaults to `"small"`.
6865+
* @default 'large'
68666866
*/
6867-
"size"?: 'small' | 'medium' | 'large';
6867+
"size"?: 'small' | 'large';
68686868
/**
68696869
* The theme determines the visual appearance of the component.
68706870
*/

core/src/components/chip/chip.base.scss

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@use "../../themes/mixins" as mixins;
22
@use "../../themes/functions.color" as colors;
33
@use "./chip.base.vars.scss" as vars;
4+
@use "sass:meta";
45

56
// Chip: Common Styles
67
// --------------------------------------------------
@@ -20,6 +21,7 @@
2021
@include mixins.border-radius(var(--border-radius));
2122
@include mixins.margin(vars.$chip-margin);
2223
@include mixins.padding(vars.$chip-padding-vertical, vars.$chip-padding-horizontal);
24+
@include mixins.typography(vars.$chip-typography);
2325

2426
display: inline-flex;
2527
position: relative;
@@ -49,12 +51,6 @@
4951
font-size: vars.$chip-size-small-font-size;
5052
}
5153

52-
:host(.chip-medium) {
53-
min-height: vars.$chip-size-medium-height;
54-
55-
font-size: vars.$chip-size-medium-font-size;
56-
}
57-
5854
:host(.chip-large) {
5955
min-height: vars.$chip-size-large-height;
6056

@@ -110,6 +106,8 @@
110106

111107
:host(.ion-color.chip-bold.chip-outline) {
112108
border-color: vars.$chip-hue-bold-semantic-outline-border-color;
109+
110+
background: vars.$chip-outline-bold-semantic-bg; //native would be transparent, else it would be whatevers in ion-color.chip-bold
113111
}
114112

115113
// Subtle
@@ -120,6 +118,8 @@
120118

121119
:host(.ion-color.chip-subtle.chip-outline) {
122120
border-color: colors.current-color(shade, $subtle: true);
121+
122+
background: vars.$chip-outline-subtle-semantic-bg;
123123
}
124124

125125
// Outline Chip
@@ -130,11 +130,6 @@
130130
border-style: solid;
131131
}
132132

133-
:host(.chip-outline),
134-
:host(.chip-outline.ion-color) {
135-
background: vars.$chip-outline-bg;
136-
}
137-
138133
// Chip States
139134
// ---------------------------------------------
140135

@@ -210,10 +205,14 @@
210205

211206
// Avatar
212207
::slotted(ion-avatar) {
208+
// width: vars.$chip-avatar-size;
209+
// height: vars.$chip-avatar-size;
210+
// @error vars.$chip-avatar-size;
211+
@if vars.$chip-avatar-size != "unset" {
212+
width: vars.$chip-avatar-size;
213+
height: vars.$chip-avatar-size;
214+
}
213215
flex-shrink: 0;
214-
215-
width: vars.$chip-avatar-size;
216-
height: vars.$chip-avatar-size;
217216
}
218217

219218
::slotted(ion-avatar:first-child) {

core/src/components/chip/chip.base.vars.scss

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ $chip-hue-bold-semantic-outline-border-color: var(--ion-chip-hue-bold-semantic-o
7676
/// @prop - Outline border width
7777
$chip-outline-border-width: var(--ion-chip-variant-outline-border-width);
7878

79-
/// @prop - Outline chip background color
80-
$chip-outline-bg: var(--ion-chip-variant-outline-bg);
79+
/// @prop - Outline bold chip background color for semantic colors
80+
$chip-outline-bold-semantic-bg: var(--ion-chip-hue-bold-semantic-outline-bg);
81+
82+
/// @prop - Subtle chip background color for semantic colors
83+
$chip-hue-subtle-semantic-bg: var(--ion-chip-hue-subtle-semantic-bg);
84+
85+
/// @prop - Outline subtle chip background color for semantic colors
86+
$chip-outline-subtle-semantic-bg: var(--ion-chip-hue-subtle-semantic-outline-bg);
8187

8288
/// @prop - Focus ring color
8389
$chip-focus-ring-color: var(--ion-chip-state-focus-ring-color);
@@ -128,7 +134,7 @@ $chip-icon-last-child-margin: var(--ion-chip-icon-last-child-margin);
128134
$chip-icon-last-child-margin-start: var(--ion-chip-icon-last-child-margin-start);
129135

130136
/// @prop - Avatar size
131-
$chip-avatar-size: var(--ion-chip-avatar-size);
137+
$chip-avatar-size: var(--ion-chip-avatar-size, revert-layer);
132138

133139
/// @prop - Avatar margin vertical for first child
134140
$chip-avatar-first-child-margin-vertical: var(--ion-chip-avatar-first-child-margin-vertical);
@@ -147,3 +153,14 @@ $chip-avatar-last-child-margin-start: var(--ion-chip-avatar-last-child-margin-st
147153

148154
/// @prop - Avatar margin end for last child
149155
$chip-avatar-last-child-margin-end: var(--ion-chip-avatar-last-child-margin-end);
156+
157+
/// @prop - Typography styles for the chip
158+
$chip-typography: (
159+
font-family: var(--ion-chip-typography-font-family),
160+
font-size: var(--ion-chip-typography-font-size),
161+
font-weight: var(--ion-chip-typography-font-weight),
162+
letter-spacing: var(--ion-chip-typography-letter-spacing),
163+
line-height: var(--ion-chip-typography-line-height),
164+
text-decoration: var(--ion-chip-typography-text-decoration),
165+
text-transform: var(--ion-chip-typography-text-transform),
166+
);

core/src/components/chip/chip.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ export class Chip implements ComponentInterface {
6464
/**
6565
* Set to `"small"` for a chip with less height and padding.
6666
*
67-
* Defaults to `"medium"`.
67+
* Defaults to `"small"`.
6868
*/
69-
@Prop() size?: 'small' | 'medium' | 'large' = 'medium';
69+
@Prop() size?: 'small' | 'large' = 'large';
7070

7171
render() {
7272
const { hue, size } = this;

core/src/themes/ionic/default.tokens.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
import * as colorTokens from 'outsystems-design-tokens/tokens/color scheme.json';
2+
import * as primitiveTokens from 'outsystems-design-tokens/tokens/primitives.json';
3+
import * as lightTokens from 'outsystems-design-tokens/tokens/theme/light.json';
4+
import * as typographyTokens from 'outsystems-design-tokens/tokens/typography.json';
5+
6+
import { currentColor, cachedResolveOsToken } from '../../utils/theme';
17
import { defaultTheme as baseDefaultTheme } from '../base/default.tokens';
28
import type { DefaultTheme } from '../themes.interfaces';
39

410
import { darkTheme } from './dark.tokens';
511
import { lightTheme } from './light.tokens';
612

13+
const tokenMap = {
14+
colorTokens,
15+
primitiveTokens,
16+
lightTokens,
17+
typographyTokens,
18+
};
19+
720
export const defaultTheme: DefaultTheme = {
821
...baseDefaultTheme,
922

@@ -76,4 +89,102 @@ export const defaultTheme: DefaultTheme = {
7689
xxxl: 'var(--ion-radii-1000)',
7790
xxxxl: 'var(--ion-radii-full)',
7891
},
92+
93+
components: {
94+
IonChip: {
95+
margin: '0px',
96+
padding: {
97+
vertical: primitiveTokens.scale['150'].$value,
98+
horizontal: primitiveTokens.scale['200'].$value,
99+
},
100+
typography: cachedResolveOsToken(typographyTokens.body.sm.medium.$value, tokenMap),
101+
lineHeight: primitiveTokens.font['line-height']['full'].$value,
102+
103+
// Sizes
104+
size: {
105+
small: {
106+
height: primitiveTokens.scale['600'].$value,
107+
fontSize: primitiveTokens.font['font-size']['300'].$value,
108+
},
109+
large: {
110+
height: primitiveTokens.scale['800'].$value,
111+
fontSize: primitiveTokens.font['font-size']['350'].$value,
112+
},
113+
},
114+
115+
// States
116+
state: {
117+
disabled: {
118+
opacity: '0.4',
119+
},
120+
focus: {
121+
ring: {
122+
color: lightTokens.primitives.blue['400'].$value,
123+
width: primitiveTokens.scale['050'].$value,
124+
},
125+
},
126+
},
127+
128+
// Shapes
129+
shape: {
130+
soft: {
131+
borderRadius: primitiveTokens.scale['100'].$value,
132+
},
133+
round: {
134+
borderRadius: primitiveTokens.scale['400'].$value,
135+
},
136+
rectangular: {
137+
borderRadius: primitiveTokens.scale['0'].$value,
138+
},
139+
},
140+
141+
// Hues
142+
hue: {
143+
bold: {
144+
bg: cachedResolveOsToken(colorTokens.bg.neutral.bold.default, tokenMap),
145+
color: lightTokens.primitives.base.white.$value,
146+
147+
outline: {
148+
borderColor: lightTokens.primitives.neutral['1200'].$value,
149+
},
150+
151+
// Any of the semantic colors like primary, secondary, etc.
152+
semantic: {
153+
color: currentColor('contrast'),
154+
155+
outline: {
156+
borderColor: currentColor('shade'),
157+
bg: currentColor('base'),
158+
},
159+
},
160+
},
161+
subtle: {
162+
bg: cachedResolveOsToken(lightTokens.primitives.neutral['100'], tokenMap),
163+
color: lightTokens.primitives.neutral['800'].$value,
164+
165+
outline: {
166+
borderColor: lightTokens.primitives.neutral['300'].$value,
167+
},
168+
169+
semantic: {
170+
outline: {
171+
borderColor: currentColor('shade', null, true),
172+
bg: currentColor('base', null, true),
173+
},
174+
},
175+
},
176+
},
177+
178+
// Variants
179+
variant: {
180+
outline: {
181+
borderWidth: primitiveTokens.scale['025'].$value,
182+
},
183+
},
184+
185+
icon: {
186+
size: primitiveTokens.font['font-size']['400'].$value,
187+
},
188+
},
189+
},
79190
};

0 commit comments

Comments
 (0)