-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(icon-button-toggle): create new web component icon-button-toggle (…
- Loading branch information
Showing
9 changed files
with
104 additions
and
1 deletion.
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
17 changes: 17 additions & 0 deletions
17
libs/components/src/icon-button-toggle/icon-button-toggle.scss
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,17 @@ | ||
:host { | ||
border-radius: 50%; | ||
color: var(--cv-theme-on-surface-variant); | ||
} | ||
|
||
:host([disabled]) { | ||
background-color: transparent; | ||
} | ||
|
||
:host([on]) { | ||
--mdc-ripple-press-opacity: 0.16; | ||
--mdc-ripple-hover-opacity: 0.12; | ||
--mdc-ripple-focus-opacity: 0.16; | ||
|
||
background-color: var(--cv-theme-primary-8); | ||
color: var(--cv-theme-primary); | ||
} |
11 changes: 11 additions & 0 deletions
11
libs/components/src/icon-button-toggle/icon-button-toggle.spec.ts
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,11 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
import { it, describe, expect } from 'vitest'; | ||
import { CovalentIconButtonToggle } from './icon-button-toggle'; | ||
|
||
describe('Icon button toggle', () => { | ||
it('should work', () => { | ||
expect(new CovalentIconButtonToggle()).toBeDefined(); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
libs/components/src/icon-button-toggle/icon-button-toggle.stories.js
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,32 @@ | ||
import './icon-button-toggle'; | ||
import iconList from '../../../icons/material-codepoints.json'; | ||
|
||
export default { | ||
title: 'Components/Icon Button Toggle', | ||
argTypes: { | ||
onIcon: { | ||
control: 'select', | ||
options: Object.keys(iconList), | ||
}, | ||
offIcon: { | ||
control: 'select', | ||
options: Object.keys(iconList), | ||
}, | ||
}, | ||
args: { | ||
onIcon: 'flashlight_on', | ||
offIcon: 'flashlight_off', | ||
disabled: false, | ||
on: false, | ||
}, | ||
}; | ||
|
||
const Template = ({ disabled, onIcon, offIcon, on }) => { | ||
return ` | ||
<cv-icon-button-toggle onIcon="${onIcon}" offIcon="${offIcon}"${ | ||
disabled ? ` disabled` : `` | ||
}${on ? ' on' : ''}> | ||
</cv-icon-button-toggle>`; | ||
}; | ||
|
||
export const Basic = Template.bind({}); |
22 changes: 22 additions & 0 deletions
22
libs/components/src/icon-button-toggle/icon-button-toggle.ts
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,22 @@ | ||
import { css, unsafeCSS } from 'lit'; | ||
import { customElement } from 'lit/decorators.js'; | ||
import { IconButtonToggle } from '@material/mwc-icon-button-toggle/mwc-icon-button-toggle'; | ||
import styles from './icon-button-toggle.scss?inline'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'cv-icon-button-toggle': CovalentIconButtonToggle; | ||
} | ||
} | ||
|
||
@customElement('cv-icon-button-toggle') | ||
export class CovalentIconButtonToggle extends IconButtonToggle { | ||
static override styles = [ | ||
...IconButtonToggle.styles, | ||
css` | ||
${unsafeCSS(styles)} | ||
`, | ||
]; | ||
} | ||
|
||
export default CovalentIconButtonToggle; |
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
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