-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@next] refactor avatar to use design tokens (#451)
- Loading branch information
1 parent
2a82785
commit 69687ec
Showing
20 changed files
with
272 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,3 @@ | ||
// Components | ||
import '@tylertech/forge/avatar'; | ||
import type { AvatarComponent } from '@tylertech/forge/avatar'; | ||
import type { ISwitchComponent } from '@tylertech/forge/switch'; | ||
import '$src/shared'; | ||
|
||
function getAvatarElements(): NodeListOf<AvatarComponent> { | ||
return document.querySelectorAll('.content forge-avatar'); | ||
} | ||
|
||
const autoColorToggle = document.querySelector('#auto-color-checkbox') as ISwitchComponent; | ||
autoColorToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { | ||
const avatars = getAvatarElements(); | ||
avatars.forEach(avatar => avatar.autoColor = selected); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@use '../core/styles/typography'; | ||
@use './token-utils' as *; | ||
|
||
@forward './token-utils'; | ||
|
||
@mixin host() { | ||
contain: content; | ||
|
||
display: inline-block; | ||
} | ||
|
||
@mixin base() { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
overflow: hidden; | ||
|
||
transition: height #{token(transition-duration)} #{token(transition-timing)}, | ||
width #{token(transition-duration)} #{token(transition-timing)}; | ||
|
||
border-radius: #{token(shape)}; | ||
box-sizing: border-box; | ||
width: #{token(size)}; | ||
height: #{token(size)}; | ||
|
||
background-color: #{token(background)}; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
|
||
@include typography.style(subheading2); | ||
color: #{token(color)}; | ||
} | ||
|
||
@mixin base-with-image() { | ||
background-color: inherit; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@use '../core/styles/tokens/avatar/tokens'; | ||
@use '../core/styles/tokens/token-utils'; | ||
|
||
$_module: avatar; | ||
$_tokens: tokens.$tokens; | ||
|
||
@mixin provide-theme($theme) { | ||
@include token-utils.provide-theme($_module, $_tokens, $theme); | ||
} | ||
|
||
@function token($name, $type: token) { | ||
@return token-utils.token($_module, $_tokens, $name, $type); | ||
} | ||
|
||
@function declare($token) { | ||
@return token-utils.declare($_module, $token); | ||
} | ||
|
||
@mixin override($token, $token-or-value, $type: token) { | ||
@include token-utils.override($_module, $_tokens, $token, $token-or-value, $type); | ||
} | ||
|
||
@mixin tokens($includes: null, $excludes: null) { | ||
@include token-utils.tokens($_module, $_tokens, $includes, $excludes); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
@use './mixins'; | ||
@use './core' as *; | ||
|
||
// | ||
// Host | ||
// | ||
|
||
:host { | ||
@include mixins.host; | ||
@include host; | ||
} | ||
|
||
:host([hidden]) { | ||
display: none; | ||
} | ||
|
||
@include mixins.core-styles; | ||
// | ||
// Base | ||
// | ||
|
||
.forge-avatar { | ||
@include tokens; | ||
} | ||
|
||
.forge-avatar { | ||
@include base; | ||
|
||
&--image { | ||
@include base-with-image; | ||
} | ||
} |
Oops, something went wrong.