diff --git a/addon/components/layout/header.hbs b/addon/components/layout/header.hbs index 3c991f3..2ad8853 100644 --- a/addon/components/layout/header.hbs +++ b/addon/components/layout/header.hbs @@ -3,10 +3,16 @@ + {{#unless (media "isMobile")}} {{/unless}} -
+
+
{{yield}}
diff --git a/addon/components/layout/header.js b/addon/components/layout/header.js index 3a68255..c70cbe7 100644 --- a/addon/components/layout/header.js +++ b/addon/components/layout/header.js @@ -3,6 +3,7 @@ import { inject as service } from '@ember/service'; import { computed, action } from '@ember/object'; import { alias } from '@ember/object/computed'; import { isArray } from '@ember/array'; +import { tracked } from '@glimmer/tracking'; /** * Layout header component. @@ -16,6 +17,7 @@ export default class LayoutHeaderComponent extends Component { @service router; @service hostRouter; @service universe; + @alias('args.user') user; @computed('store', 'user.company_uuid') get company() { diff --git a/addon/components/layout/header/sidebar-toggle.hbs b/addon/components/layout/header/sidebar-toggle.hbs new file mode 100644 index 0000000..a5bd311 --- /dev/null +++ b/addon/components/layout/header/sidebar-toggle.hbs @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/addon/components/layout/header/sidebar-toggle.js b/addon/components/layout/header/sidebar-toggle.js new file mode 100644 index 0000000..ff277f9 --- /dev/null +++ b/addon/components/layout/header/sidebar-toggle.js @@ -0,0 +1,20 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; +import { alias } from '@ember/object/computed'; +import { tracked } from '@glimmer/tracking'; + +export default class LayoutHeaderSidebarToggleComponent extends Component { + @service universe; + @alias('universe.sidebarContext') sidebarContext; + @tracked isSidebarVisible = true; + + @action toggleSidebar() { + if (this.isSidebarVisible) { + this.sidebarContext.hideNow(); + } else { + this.sidebarContext.show(); + } + this.isSidebarVisible = !this.isSidebarVisible; + } +} diff --git a/addon/styles/addon.css b/addon/styles/addon.css index 4faa8dc..1690759 100644 --- a/addon/styles/addon.css +++ b/addon/styles/addon.css @@ -41,6 +41,7 @@ @import 'components/fleet-listing.css'; @import 'components/drawer.css'; @import 'components/full-calendar.css'; +@import 'components/sidebar-toggle.css'; /** Third party */ @import 'air-datepicker/air-datepicker.css'; diff --git a/addon/styles/components/sidebar-toggle.css b/addon/styles/components/sidebar-toggle.css new file mode 100644 index 0000000..fc9a7e3 --- /dev/null +++ b/addon/styles/components/sidebar-toggle.css @@ -0,0 +1,26 @@ +.sidebar-toggle-button-wrapper { + flex-shrink: 0; +} + +.sidebar-toggle-button-wrapper > .sidebar-toggle-button.next-org-button-trigger, +.sidebar-toggle-button-wrapper > .sidebar-toggle-button { + display: flex; + align-items: center; + justify-content: center; + padding: 0.25rem 0.25rem; +} + +.sidebar-toggle-button-wrapper > .sidebar-toggle-button > svg { + enable-background: new 0 0 50 50; + fill: rgb(249, 250, 251); + width: 20px; + height: 20px; +} + +.sidebar-toggle-button-wrapper:hover > .sidebar-toggle-button > svg { + fill: #fff; +} + +.sidebar-toggle-button-wrapper.sidebar-is-visible > .sidebar-toggle-button > svg { + /* fill: blue; */ +} diff --git a/app/components/layout/header/sidebar-toggle.js b/app/components/layout/header/sidebar-toggle.js new file mode 100644 index 0000000..c9c60a3 --- /dev/null +++ b/app/components/layout/header/sidebar-toggle.js @@ -0,0 +1 @@ +export { default } from '@fleetbase/ember-ui/components/layout/header/sidebar-toggle'; diff --git a/tests/integration/components/layout/header/sidebar-toggle-test.js b/tests/integration/components/layout/header/sidebar-toggle-test.js new file mode 100644 index 0000000..0bd4431 --- /dev/null +++ b/tests/integration/components/layout/header/sidebar-toggle-test.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | layout/header/sidebar-toggle', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.dom(this.element).hasText(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.dom(this.element).hasText('template block text'); + }); +});