-
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.
feat(switch): refactor switch component
--------- Co-authored-by: Nichols, Kieran <kieran.nichols@tylertech.com>
- Loading branch information
1 parent
f6c0946
commit 83699fd
Showing
29 changed files
with
1,700 additions
and
1,709 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@use '../../../lib/switch'; | ||
|
||
.form-switch { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.custom-switch { | ||
--primary-color: var(--forge-theme-primary); | ||
|
||
@include switch.provide-theme(( | ||
handle-on-color: var(--forge-theme-surface), | ||
handle-size: 24px, | ||
handle-off-scale: 0.67, | ||
handle-active-off-scale: 0.83, | ||
handle-on-elevation: none, | ||
track-on-color: var(--primary-color), | ||
track-width: 54px, | ||
track-height: 32px, | ||
track-border-width: 2px, | ||
track-off-border-color: #9e9e9e, | ||
icon-on-size: 16px, | ||
icon-on-color: var(--primary-color), | ||
direction: column, | ||
gap: 4px, | ||
state-layer-on-color: var(--primary-color) | ||
)); | ||
} |
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,2 +1,20 @@ | ||
import '$src/shared'; | ||
import '@tylertech/forge/switch'; | ||
import { ISwitchComponent, IconRegistry } from '@tylertech/forge'; | ||
import { tylIconEmoticonHappy, tylIconEmoticonSad } from '@tylertech/tyler-icons/extended'; | ||
import './switch.scss'; | ||
|
||
IconRegistry.define([ | ||
tylIconEmoticonHappy, | ||
tylIconEmoticonSad | ||
]); | ||
|
||
const preventSwitch = document.getElementById('prevent-switch') as ISwitchComponent; | ||
|
||
preventSwitch.addEventListener('forge-switch-change', (evt: CustomEvent) => evt.preventDefault()); | ||
|
||
const testForm = document.getElementById('test-form') as HTMLFormElement; | ||
testForm.addEventListener('submit', (evt: Event) => { | ||
evt.preventDefault(); | ||
console.log('[submit] switch value:', new FormData(testForm).get('test-switch')); | ||
}); |
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
Oops, something went wrong.