-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new split-button component
- Loading branch information
Showing
27 changed files
with
769 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div> | ||
<h3 class="forge-typography--heading2">Common</h3> | ||
<forge-split-button> | ||
<forge-button class="primary-action">Send</forge-button> | ||
<forge-menu id="split-menu"> | ||
<forge-button popover-icon></forge-button> | ||
</forge-menu> | ||
</forge-split-button> | ||
</div> | ||
|
||
<div> | ||
<h3 class="forge-typography--heading2">Multiple</h3> | ||
<forge-split-button> | ||
<forge-button class="primary-action">Button one</forge-button> | ||
<forge-button class="primary-action">Button two</forge-button> | ||
<forge-button class="primary-action">Button three</forge-button> | ||
<forge-button class="primary-action">Button four</forge-button> | ||
</forge-split-button> | ||
</div> | ||
|
||
<script type="module" src="split-button.ts"></script> |
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 @@ | ||
<%- | ||
include('./src/partials/page.ejs', { | ||
page: { | ||
title: 'Split button', | ||
includePath: './pages/split-button/split-button.ejs', | ||
options: [ | ||
{ | ||
type: 'select', | ||
label: 'Variant', | ||
id: 'opt-variant', | ||
defaultValue: 'text', | ||
options: [ | ||
{ value: 'text', label: 'Text (default)' }, | ||
{ value: 'flat', label: 'Flat' }, | ||
{ value: 'raised', label: 'Raised' }, | ||
{ value: 'outlined', label: 'Outlined' } | ||
] | ||
}, | ||
{ type: 'switch', label: 'Disabled', id: 'opt-disabled' }, | ||
{ type: 'switch', label: 'Dense', id: 'opt-dense' }, | ||
{ type: 'switch', label: 'Pill', id: 'opt-pill' } | ||
] | ||
} | ||
}) | ||
%> |
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,5 @@ | ||
forge-split-button[variant]:not([variant=text]) { | ||
.primary-action { | ||
min-width: 100px; | ||
} | ||
} |
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,42 @@ | ||
import '$src/shared'; | ||
import '@tylertech/forge/split-button'; | ||
import { IconRegistry } from '@tylertech/forge/icon'; | ||
import type { ISplitButtonComponent, SplitButtonVariant } from '@tylertech/forge/split-button'; | ||
import type { ISelectComponent } from '@tylertech/forge/select'; | ||
import type { ISwitchComponent } from '@tylertech/forge/switch'; | ||
import type { IMenuComponent } from '@tylertech/forge/menu'; | ||
import { tylIconArrowDropDown, tylIconScheduleSend, tylIconDeleteOutline, tylIconBookmarkBorder } from '@tylertech/tyler-icons/standard'; | ||
import './split-button.scss'; | ||
|
||
IconRegistry.define([tylIconArrowDropDown, tylIconScheduleSend, tylIconDeleteOutline, tylIconBookmarkBorder]); | ||
|
||
const splitMenu = document.querySelector('#split-menu') as IMenuComponent; | ||
splitMenu.options = [ | ||
{ label: 'Schedule send', value: 'schedule', leadingIcon: 'schedule_send', leadingIconType: 'component' }, | ||
{ label: 'Delete', value: 'delete', leadingIcon: 'delete_outline', leadingIconType: 'component' }, | ||
{ label: 'Save draft', value: 'save', leadingIcon: 'bookmark_border', leadingIconType: 'component' } | ||
]; | ||
|
||
const variantSelect = document.querySelector('#opt-variant') as ISelectComponent; | ||
variantSelect.addEventListener('change', ({ detail: variant }: CustomEvent<SplitButtonVariant>) => { | ||
getSplitButtons().forEach(splitButton => splitButton.variant = variant); | ||
}); | ||
|
||
const disabledToggle = document.querySelector('#opt-disabled') as ISwitchComponent; | ||
disabledToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { | ||
getSplitButtons().forEach(splitButton => splitButton.disabled = selected); | ||
}); | ||
|
||
const denseToggle = document.querySelector('#opt-dense') as ISwitchComponent; | ||
denseToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { | ||
getSplitButtons().forEach(splitButton => splitButton.dense = selected); | ||
}); | ||
|
||
const pillToggle = document.querySelector('#opt-pill') as ISwitchComponent; | ||
pillToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { | ||
getSplitButtons().forEach(splitButton => splitButton.pill = selected); | ||
}); | ||
|
||
function getSplitButtons(): ISplitButtonComponent[] { | ||
return Array.from(document.querySelectorAll<ISplitButtonComponent>('forge-split-button')); | ||
} |
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
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,16 @@ | ||
@use 'sass:map'; | ||
@use '../../utils'; | ||
@use '../../border'; | ||
@use '../button/tokens' as button; | ||
|
||
$tokens: ( | ||
min-width: utils.module-val(split-button, min-width, 0), | ||
gap: utils.module-val(split-button, gap, border.variable(thin)), | ||
|
||
focus-indicator-offset: utils.module-val(split-button, focus-indicator-offset, button.get(focus-indicator-offset)), | ||
focus-indicator-divider-offset: utils.module-ref(split-button, focus-indicator-divider-offset, gap) | ||
) !default; | ||
|
||
@function get($key) { | ||
@return map.get($tokens, $key); | ||
} |
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,5 +1,5 @@ | ||
:host { | ||
display: inline-block; | ||
display: inline-flex; | ||
} | ||
|
||
:host([hidden]) { | ||
|
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,7 @@ | ||
@use './token-utils' as *; | ||
|
||
@mixin configuration { | ||
@include tokens; | ||
|
||
#{declare(focus-indicator-offset-adjusted)}: calc(#{token(focus-indicator-offset)} + #{token(focus-indicator-divider-offset)} * 2); | ||
} |
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/split-button/tokens'; | ||
@use '../core/styles/tokens/token-utils'; | ||
|
||
$_module: split-button; | ||
$_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 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,4 @@ | ||
{ | ||
"$schema": "../../../node_modules/@tylertech/forge-cli/config/build-schema.json", | ||
"extends": "../build.json" | ||
} |
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,2 @@ | ||
@forward './configuration'; | ||
@forward './token-utils' show provide-theme; |
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,12 @@ | ||
import { defineCustomElement } from '@tylertech/forge-core'; | ||
|
||
import { SplitButtonComponent } from './split-button'; | ||
|
||
export * from './split-button-adapter'; | ||
export * from './split-button-constants'; | ||
export * from './split-button-foundation'; | ||
export * from './split-button'; | ||
|
||
export function defineSplitButtonComponent(): void { | ||
defineCustomElement(SplitButtonComponent); | ||
} |
Oops, something went wrong.