Skip to content

Commit

Permalink
Switched css to scss file(not compiled yet), added last 2 component t…
Browse files Browse the repository at this point in the history
…est, removed unused testing variables. ran tests 100% all across
  • Loading branch information
sreidthomas committed Feb 5, 2025
1 parent a4c1a00 commit bbd3a23
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 5 deletions.
184 changes: 183 additions & 1 deletion src/stable/components/GovBanner/GovBanner.scss
Original file line number Diff line number Diff line change
@@ -1 +1,183 @@
// Only Use For Complex Styling Tasks such as looping, functions, variables, etc
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/mixins";

.banner-container {
width: 100%;
background-color: #004445;
color: white;
}

.banner-header {
display: flex;
justify-content: center;
align-items: center;
padding: 0.5rem 1rem;
max-width: 1200px;
margin: 0 auto;
}

.title-section {
display: flex;
align-items: center;
gap: 1rem;
}

.city-name {
font-weight: bold;
text-transform: uppercase;
display: inline-flex;
flex-direction: column;
align-items: center;

> span {
display: inline-flex;
flex-direction: column;
align-items: center;

&:first-child {
font-size: 0.75rem;
line-height: 1;
}

&:last-child {
font-size: 1rem;
}
}
}

.official-text {
display: flex;
align-items: center;
gap: 0.25rem;
font-size: 0.875rem;
}

.know-text {
display: flex;
align-items: center;
text-decoration: underline;
cursor: pointer;
margin-left: 0.25rem;
}

.chevron-container {
background: none;
border: none;
padding: 0;
color: inherit;
cursor: pointer;
display: inline-flex;
align-items: center;
margin-left: 0.25rem;

svg {
transition: transform 0.2s ease;
width: 12px;
height: 12px;
}

&[aria-expanded='true'] svg {
transform: rotate(180deg);
}
}

.content-container {
background-color: #f8f9fa;
width: 100%;
border-top: 1px solid #dee2e6;
}

.info-section {
display: flex;
justify-content: space-between;
max-width: 1200px;
margin: 0 auto;
padding: 1.5rem 1rem;
gap: 2rem;
}

.info-item {
display: flex;
gap: 1rem;
align-items: flex-start;
flex: 1;

.info-title {
margin: 0 0 0.5rem 0;
font-size: 1rem;
font-weight: 600;
color: #212529;
}

p {
margin: 0;
line-height: 1.5;
color: #495057;
font-size: 0.875rem;
}
}

.icon-circle {
width: 48px;
height: 48px;
border-radius: 50%;
border: 2px solid #dee2e6;
background-color: white;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}

.gov-icon,
.lock-icon {
font-size: 1.5rem;
color: #004445;
}

// Tablet and Mobile shared styles
@include media-breakpoint-down(lg) {
.official-text {
display: flex;
flex-direction: column;
white-space: nowrap;
min-width: 0;
gap: 0.0625rem;
}

.know-text {
display: flex;
justify-content: center;
margin-top: 0.0625rem;
width: 100%;
}

.city-name {
margin-top: 0.25rem;
flex-shrink: 0;
}
}

// Mobile-specific overrides
@include media-breakpoint-down(sm) {
.banner-header {
justify-content: flex-start;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}

.official-text {
align-items: flex-start;
}

.info-section {
flex-direction: column;
padding: 1rem;
gap: 1.5rem;
}

.info-item {
width: 100%;
}
}
28 changes: 24 additions & 4 deletions src/stable/stories/govbanner.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html } from 'lit-html';
import { expect } from '@storybook/jest';
import { within, userEvent } from '@storybook/testing-library';
import { userEvent } from '@storybook/testing-library';
import '../components/GovBanner/cod-gov-banner';

export default {
Expand All @@ -15,7 +15,6 @@ export const Default = {
export const ExpandedBehavior = {
render: () => html` <cod-gov-banner> </cod-gov-banner> `,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const govBanner = canvasElement.querySelector('cod-gov-banner');
const shadow = govBanner.shadowRoot;

Expand All @@ -33,7 +32,15 @@ export const ExpandedBehavior = {

// Test clicking the header
const toggle = shadow.querySelector('.chevron-container');

// Test event dispatch on click
const clickEventPromise = new Promise(resolve => {
govBanner.addEventListener('expandedchange', (e) => resolve(e.detail));
});
await userEvent.click(toggle);
const clickEventDetail = await clickEventPromise;
expect(clickEventDetail.expanded).toBe(true);

await expect(govBanner.expanded).toBe(true);
checkExpandedState(true);

Expand All @@ -42,14 +49,27 @@ export const ExpandedBehavior = {
await expect(govBanner.expanded).toBe(false);
checkExpandedState(false);

// Test changing expanded property
// Test changing expanded property and event dispatch
const propertyEventPromise = new Promise(resolve => {
govBanner.addEventListener('expandedchange', (e) => resolve(e.detail));
});
govBanner.expanded = true;
const propertyEventDetail = await propertyEventPromise;
expect(propertyEventDetail.expanded).toBe(true);

await expect(govBanner.expanded).toBe(true);
checkExpandedState(true);
expect(govBanner.getAttribute('expanded')).toBe('true');

// Test changing expanded attribute
govBanner.setAttribute('expanded', 'false');
await expect(govBanner.expanded).toBe(false);
checkExpandedState(false);
expect(govBanner.getAttribute('expanded')).toBe('false');

// Test setting same value (should not trigger event)
govBanner.expanded = false;
await expect(govBanner.expanded).toBe(false);
checkExpandedState(false);
},
};
};

0 comments on commit bbd3a23

Please sign in to comment.