Skip to content

Commit

Permalink
Merge pull request #162 from US-CBP/bugfix/universal-header-logo
Browse files Browse the repository at this point in the history
Bugfix/universal header logo
  • Loading branch information
dgibson666 authored Jul 16, 2024
2 parents 3901091 + 3bd81bc commit 60f03ad
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/web-components/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<base href="./" target="_self" />

<link rel="stylesheet" type="text/css" href="assets/css/storybook-canvas.css">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ The Button component represents a UI control visually styled like a button (rega

### Additional Notes and Considerations

* Links/anchors should only be used for navigation; the `button` element is the preferred control for all other types of UI interactions.
* Links/anchors should only be used for navigation; the `button` element is the preferred control for all other types of UI interactions.
* If you hide a text label at small screen sizes (e.g., via `cbp-hide`) and only show an icon, the intent is for the button to be shown as the "square" variant. This cannot be handled internally to the component and should be implemented by the application.
41 changes: 38 additions & 3 deletions packages/web-components/src/components/cbp-hide/cbp-hide.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Prop, Element, Host, h } from '@stencil/core';
import { Component, Prop, Element, Event, EventEmitter, Host, h } from '@stencil/core';
import { setCSSProps } from '../../utils/utils';

/**
Expand All @@ -9,6 +9,9 @@ import { setCSSProps } from '../../utils/utils';
styleUrl: 'cbp-hide.scss'
})
export class CbpHide {

private hidden=false;

@Element() host: HTMLElement;

/** Specifies the host's display when visible. The default is `inline`, which is the default display of a custom element. */
Expand All @@ -28,12 +31,44 @@ export class CbpHide {
@Prop() sx: any = {};


/** A custom event emitted when the accordion item control is activated. */
@Event({
eventName: 'hideToggle',
cancelable: true,
bubbles: true,
}) hideToggle: EventEmitter;

// Callback functions for the media query event listeners
doHideAt(mql) {
mql.matches ? this.host.style.setProperty('display', 'none') : this.host.style.setProperty('display', this.display);
if (mql.matches) {
this.host.style.setProperty('display', 'none')
this.hidden=true;
}
else {
this.host.style.setProperty('display', this.display);
this.hidden=false;
}

this.hideToggle.emit({
host: this.host,
hidden: this.hidden,
});
}

doVisuallyHideAt(mql) {
mql.matches ? this.host.classList.add('cbp-visually-hidden') : this.host.classList.remove('cbp-visually-hidden');
if (mql.matches) {
this.host.classList.add('cbp-visually-hidden')
this.hidden=true;
}
else {
this.host.classList.remove('cbp-visually-hidden');
this.hidden=false;
}

this.hideToggle.emit({
host: this.host,
hidden: this.hidden,
});
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default {
},
};


const UniversalHeaderTemplate = ({ logoSrcLg, logoSrcSm, username, isLoggedIn }) => {
return `
<cbp-universal-header
Expand Down Expand Up @@ -47,7 +48,11 @@ const UniversalHeaderTemplate = ({ logoSrcLg, logoSrcSm, username, isLoggedIn })
</cbp-button>
</li>
<li>
<cbp-button color="secondary" fill="ghost" context="dark-always">
<cbp-button
color="secondary"
fill="ghost"
context="dark-always"
>
<cbp-icon name="user"></cbp-icon>
<cbp-hide
visually-hide-at="max-width: 64em"
Expand All @@ -72,7 +77,7 @@ const UniversalHeaderTemplate = ({ logoSrcLg, logoSrcSm, username, isLoggedIn })

export const UniversalHeader = UniversalHeaderTemplate.bind({});
UniversalHeader.args = {
username: 'John Smithington',
username: 'HASHIDX',
isLoggedIn: true,
};
UniversalHeader.argTypes = {
Expand Down

0 comments on commit 60f03ad

Please sign in to comment.