Skip to content

Commit

Permalink
feat(app-bar): refactor to use tokens and new patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
DRiFTy17 committed Nov 22, 2023
1 parent 9cc3e05 commit a3933e1
Show file tree
Hide file tree
Showing 53 changed files with 926 additions and 926 deletions.
33 changes: 0 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"@material/select": "^14.0.0",
"@material/shape": "^14.0.0",
"@material/theme": "^14.0.0",
"@material/top-app-bar": "^14.0.0",
"@material/touch-target": "^14.0.0",
"@material/typography": "^14.0.0",
"@tylertech/forge-core": "^2.3.0",
Expand Down
9 changes: 6 additions & 3 deletions src/dev/pages/app-bar/app-bar.ejs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<forge-app-bar id="forge-app-bar-example" title-text="App bar">
<forge-app-bar id="forge-app-bar-example" title-text="App Bar" href="javascript: void(0);">
<forge-icon slot="logo" external external-type="custom" name="forge_logo"></forge-icon>

<forge-app-bar-menu-button slot="start" id="forge-app-bar-example-menu-button"></forge-app-bar-menu-button>

<forge-app-bar-search id="app-bar-search" slot="center">
<input type="text" placeholder="Search" aria-label="Search" />
<forge-icon-button id="app-bar-search-action" slot="action">
<forge-icon-button id="app-bar-search-action" slot="action" aria-label="Search by voice">
<forge-icon name="keyboard_voice"></forge-icon>
</forge-icon-button>
</forge-app-bar-search>


<forge-app-bar-help-button slot="end"></forge-app-bar-help-button>
<forge-app-bar-notification-button slot="end"></forge-app-bar-notification-button>
<forge-app-bar-app-launcher-button slot="end"></forge-app-bar-app-launcher-button>


<forge-button slot="end">Sign in</forge-button>

<forge-app-bar-profile-button
slot="end"
avatar-text="First Last"
Expand Down
20 changes: 15 additions & 5 deletions src/dev/pages/app-bar/app-bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,27 @@
{
type: 'select',
label: 'Theme',
id: 'app-bar-theme-select',
id: 'opt-theme',
defaultValue: '',
options: [
{ label: 'Default', value: '' },
{ label: 'White', value: 'white' }
]
},
{ type: 'text-field', label: 'Title text', id: 'app-bar-title-input', defaultValue: 'App bar' },
{ type: 'switch', label: 'Raised', id: 'app-bar-raised-toggle', defaultValue: true },
{ type: 'switch', label: 'Show tabs', id: 'app-bar-show-tabs-toggle', defaultValue: true },
{ type: 'switch', label: 'Use profile card builder', id: 'app-bar-profile-card-builder-toggle' }
{
type: 'select',
label: 'Elevation',
id: 'opt-elevation',
defaultValue: 'raised',
options: [
{ label: 'Raised (default)', value: 'raised' },
{ label: 'None ', value: '' }
]
},
{ type: 'text-field', label: 'Title text', id: 'opt-title-text', defaultValue: 'App bar' },
{ type: 'switch', label: 'Href', id: 'opt-href', defaultValue: true },
{ type: 'switch', label: 'Show tabs', id: 'opt-show-tabs', defaultValue: true },
{ type: 'switch', label: 'Use profile card builder', id: 'opt-profile-card-builder' }
]
}
})
Expand Down
65 changes: 31 additions & 34 deletions src/dev/pages/app-bar/app-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '@tylertech/forge/tabs';

// Icons
import type {
AppBarElevation,
IAppBarComponent,
IAppBarHelpButtonComponent,
IAppBarMenuButtonComponent,
Expand Down Expand Up @@ -45,7 +46,6 @@ IconRegistry.define([
tylIconKeyboardVoice
]);

const pageAppBar = document.querySelector('forge-app-bar#page-app-bar') as IAppBarComponent;
const appBar = document.querySelector('forge-app-bar#forge-app-bar-example') as IAppBarComponent;
const appBarSearch = appBar.querySelector('forge-app-bar-search#app-bar-search') as IAppBarSearchComponent;
const appBarProfileButton = appBar.querySelector('forge-app-bar-profile-button') as IAppBarProfileButtonComponent;
Expand Down Expand Up @@ -79,7 +79,36 @@ appBarSearch.addEventListener('forge-app-bar-search-input', ({ detail }) => {
document.body.appendChild(toast);
});

const useProfileCardBuilderToggle = document.querySelector('#app-bar-profile-card-builder-toggle') as ISwitchComponent;
const themeSelect = document.querySelector('#opt-theme') as ISelectComponent;
themeSelect.addEventListener('change', () => {
appBar.theme = themeSelect.value || '';
});

const elevationSelect = document.querySelector('#opt-elevation') as ISelectComponent;
elevationSelect.addEventListener('change', ({ detail }) => {
appBar.elevation = detail as AppBarElevation;
});

const titleInput = document.querySelector('#opt-title-text') as HTMLInputElement;
titleInput.addEventListener('input', () => {
appBar.titleText = titleInput.value;
});

const hrefToggle = document.querySelector('#opt-href') as ISwitchComponent;
hrefToggle.addEventListener('forge-switch-change', ({ detail: selected }) => {
appBar.href = selected ? 'javascript: void(0);' : undefined;
});

const showTabsToggle = document.querySelector('#opt-show-tabs') as ISwitchComponent;
showTabsToggle.addEventListener('forge-switch-change', ({ detail: selected }) => {
if (selected) {
appBar.appendChild(appBarTabs);
} else {
appBarTabs.remove();
}
});

const useProfileCardBuilderToggle = document.querySelector('#opt-profile-card-builder') as ISwitchComponent;
useProfileCardBuilderToggle.addEventListener('forge-switch-change', ({ detail: selected }) => {
appBarProfileButton.profileCardBuilder = selected ? profileCardBuilder : undefined;
});
Expand Down Expand Up @@ -113,35 +142,3 @@ function profileCardBuilder(): HTMLElement {
listElement.appendChild(buildListItemElement('My Preferences', 'settings', 'preferences'));
return listElement;
}

const appBarRaisedToggle = document.querySelector('#app-bar-raised-toggle') as ISwitchComponent;
appBarRaisedToggle.addEventListener('forge-switch-change', ({ detail: selected }) => {
appBar.raised = selected;
pageAppBar.raised = selected;
});

const appBarTitleInput = document.querySelector('#app-bar-title-input') as HTMLInputElement;
appBarTitleInput.addEventListener('input', () => {
appBar.titleText = appBarTitleInput.value;
});

const appBarThemeSelect = document.querySelector('#app-bar-theme-select') as ISelectComponent;
appBarThemeSelect.addEventListener('change', () => {
if (appBarThemeSelect.value) {
appBar.setAttribute('theme', appBarThemeSelect.value);
pageAppBar.setAttribute('theme', appBarThemeSelect.value);
} else {
appBar.removeAttribute('theme');
pageAppBar.removeAttribute('theme');
}
});

const showAppBarTabsToggle = document.querySelector('#app-bar-show-tabs-toggle') as ISwitchComponent;
showAppBarTabsToggle.addEventListener('forge-switch-change', ({ detail: selected }) => {
if (selected) {
appBarTabs.style.removeProperty('display');
} else {
appBarTabs.style.display = 'none';
}
});

1 change: 0 additions & 1 deletion src/dev/pages/menu/menu.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<forge-menu id="forge-menu-example">
<!-- <button type="button">Show menu</button> -->
<forge-button variant="raised">Show menu</forge-button>
</forge-menu>

Expand Down
6 changes: 1 addition & 5 deletions src/dev/src/partials/header.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<forge-app-bar slot="header" id="page-app-bar">
<a slot="title" href="/">
<h1 class="forge-typography--heading4"><%= site.title %><%= title ? ` - ${title}` : null %></h1>
<forge-ripple></forge-ripple>
</a>
<forge-app-bar slot="header" id="page-app-bar" title-text="<%= site.title %><%= title ? ` - ${title}` : null %>" href="/">
<forge-icon name="forge_logo" slot="logo"></forge-icon>
<forge-icon-button slot="end" id="dark-theme-button" aria-label="Toggle theme">
<forge-icon name="brightness_3"></forge-icon>
Expand Down
4 changes: 2 additions & 2 deletions src/dev/src/styles/_header.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#page-app-bar {
--forge-app-bar-theme-background: var(--forge-theme-secondary);
--forge-app-bar-theme-on-background: var(--forge-theme-on-secondary);
--forge-app-bar-background: var(--forge-theme-secondary);
--forge-app-bar-foreground: var(--forge-theme-on-secondary);

a[slot=title] {
text-decoration: none;
Expand Down
Loading

0 comments on commit a3933e1

Please sign in to comment.