Skip to content

Commit

Permalink
update to remove redundant statement
Browse files Browse the repository at this point in the history
  • Loading branch information
SBBlee committed Jul 31, 2024
2 parents 6101576 + ddf1b29 commit 3d9f418
Show file tree
Hide file tree
Showing 27 changed files with 526 additions and 323 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# v1.0.21 (Tues May 14 2024)

#### 🚀 Enhancement

- Add Close Button to Alert Component [by @sreidthomas](https://github.com/CityOfDetroit/COD-Design-System/pull/208)
- Encapsulate SCSS-generated CSS with each component [by @sreidthomas](https://github.com/CityOfDetroit/COD-Design-System/pull/136)
- Create table v2 to resolve performance issues [by @maxatdetroit](https://github.com/CityOfDetroit/COD-Design-System/pull/207)

#### 🏠 Internal

- Resolve more ESLint errors [by @maxatdetroit](https://github.com/CityOfDetroit/COD-Design-System/pull/206)
- Use common story arguments [by @maxatdetroit](https://github.com/CityOfDetroit/COD-Design-System/pull/210)

#### Authors: 2

- Shakira Reid-Thomas ([@sreidthomas](https://github.com/sreidthomas))
- Max Morgan ([@maxatdetroit](https://github.com/maxatdetroit))

# v1.0.20 (Mon Apr 22 2024)

#### 🐛 Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion build/assets/js/main.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/components/atoms/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class Alert extends HTMLElement {
this.shadowRoot.appendChild(bootStyles);
this.shadowRoot.appendChild(variableStyles);
this.shadowRoot.appendChild(alertStyles);

// alert attributes

const icon = this.getAttribute('data-icon');
Expand Down Expand Up @@ -92,5 +93,16 @@ export default class Alert extends HTMLElement {
iconClass,
].join(' ');
this.shadowRoot.appendChild(this.alert);

// Check if the alert is closeable
const isCloseable = this.hasAttribute('closeable');

if (isCloseable) {
// Add close button
const closeButton = document.createElement('cod-button');
closeButton.className = 'btn-close';
closeButton.addEventListener('click', () => this.remove());
this.alert.appendChild(closeButton);
}
}
}
58 changes: 58 additions & 0 deletions src/components/organisms/TableV2/TableV2.css

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

1 change: 1 addition & 0 deletions src/components/organisms/TableV2/TableV2.css.map

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

64 changes: 64 additions & 0 deletions src/components/organisms/TableV2/TableV2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import styles from '!!raw-loader!./TableV2.css';
import varStyles from '!!raw-loader!../../../shared/variables.css';
import bootstrapStyles from '!!raw-loader!../../../shared/themed-bootstrap.css';

class TableV2 extends HTMLElement {
static observedAttributes = [];

constructor() {
// Always call super first in constructor
super();
// Create a shadow root
const shadow = this.attachShadow({ mode: 'open' });
// Add styles
const bootStyles = document.createElement('style');
bootStyles.textContent = bootstrapStyles;
const variableStyles = document.createElement('style');
variableStyles.textContent = varStyles;
const itemStyles = document.createElement('style');
itemStyles.textContent = styles;
shadow.appendChild(bootStyles);
shadow.appendChild(variableStyles);
shadow.appendChild(itemStyles);
}

connectedCallback() {
// TODO: Add support for: scrollable,
// custom extra classes, dark, hover, and
// striped columns/rows.
this.shadowRoot.append(...this.childNodes);
this._addTableClasses();
this._slotCells();
}

_addTableClasses() {
const table = this.shadowRoot.querySelector('table');
table.classList.add('table');

const isStacked = this.hasAttribute('table-stacked');
if (isStacked) {
table.classList.add('table-stacked');
}
}

_slotCells() {
const cells = this.shadowRoot.querySelectorAll('td');
const cellHeaders = this.shadowRoot.querySelectorAll('th');
[...cells, ...cellHeaders].forEach((cellNode, idx) => {
const children = cellNode.childNodes;
const contentDiv = document.createElement('div');
contentDiv.classList.add('content');
const slotName = `slot-${idx}`;
contentDiv.setAttribute('slot', slotName);
contentDiv.append(...children);

const slot = document.createElement('slot');
slot.setAttribute('name', slotName);
cellNode.appendChild(slot);

this.appendChild(contentDiv);
});
}
}

export { TableV2 as default };
65 changes: 65 additions & 0 deletions src/components/organisms/TableV2/TableV2.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@use '../../../scss/mixins/table';
@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';
@import 'bootstrap/scss/mixins/breakpoints';

@include media-breakpoint-down(lg) {
table.table-stacked {
& slot {
display: block;
flex: 1 1 0px;
padding: 0.5em 0.5em;
}

// Header & body styles.
& thead {
// Move table header off the screen to hide from
// sited viewers but remain enabled for screen readers
// and other AT.
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
}

// Row styles.
& tr {
display: block;
border-top-width: 0;
width: 100%;
border-bottom: 2px solid var(--bs-black);

&:nth-child(1) {
border-top: 2px solid var(--bs-black);
}
}

// Cell header styles.
& th {
@include table.th-td-stacked-inline-styles;

& div.content {
@include table.cell-content-stacked-inline-styles;
}
}

& th[data-label] {
@include table.th-td-labeled-stacked-inline-styles;
}

// Cell styles.
& td {
@include table.th-td-stacked-inline-styles;

& div.content {
@include table.cell-content-stacked-inline-styles;
}
}

& td[data-label] {
@include table.th-td-labeled-stacked-inline-styles;
}
}
}
2 changes: 2 additions & 0 deletions src/components/organisms/TableV2/cod-table-v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import TableV2 from './TableV2';
customElements.define('cod-table-v2', TableV2);
112 changes: 112 additions & 0 deletions src/shared/js/storybook/args-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const COMMON_STORY_ARGS = {
disabled: {
control: { type: 'boolean' },
},
required: {
control: { type: 'boolean' },
},
checked: {
control: { type: 'boolean' },
},
readOnly: {
control: { type: 'boolean' },
},
bootstrapColor: {
control: { type: 'select' },
options: [
'primary',
'secondary',
'success',
'info',
'warning',
'danger',
'light',
'dark',
'accent-primary',
'accent-secondary',
],
},
// TODO: Use bootstrap color names. Issue #202.
numberColor: {
control: { type: 'select' },
options: [
'color-1',
'color-2',
'color-3',
'color-4',
'color-5',
'color-light',
'color-dark',
],
},
order: {
control: { type: 'select' },
options: ['left', 'right'],
},
// TODO: Make the following two size attr names/values
// consistent. Issue #202.
size: {
control: { type: 'select' },
options: ['sm', 'md', 'lg', 'xl'],
},
longSize: {
control: { type: 'select' },
options: ['small', 'medium', 'large', 'x-large'],
},
icon: {
control: { type: 'select' },
options: [
'bicycle',
'bounding-box',
'bounding-box-circle',
'building',
'building-fill',
'buildings',
'buildings-fill',
'bus-front',
'bus-front-fill',
'calendar',
'calendar-fill',
'calendar-date',
'calendar-date-fill',
'cash',
'check-circle',
'check-circle-fill',
'chevron-right',
'chevron-right-circle',
'chevron-right-circle-fill',
'chevron-left',
'chevron-left-circle',
'chevron-left-circle-fill',
'chevron-up',
'chevron-up-circle',
'chevron-up-circle-fill',
'chevron-down',
'chevron-down-circle',
'chevron-down-circle-fill',
'currency-dollar',
'exclamation-circle',
'exclamation-circle-fill',
'exclamation-triangle',
'file-earmark',
'funnel',
'funnel-fill',
'house',
'house-fill',
'list-task',
'newspaper',
'no-parking',
'no-parking-fill',
'journals',
'p-circle',
'p-circle-fill',
'toilet',
'universal-access',
'universal-access-circle',
'wifi',
'wifi-off',
].sort(),
},
};

export { COMMON_STORY_ARGS };
7 changes: 5 additions & 2 deletions src/stories/actionbutton.stories.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { html } from 'lit-html';
import '../components/atoms/ActionButton/cod-action-button';
import '../components/atoms/Icon/cod-icon';
import IconStory from './icon.stories';
import { COMMON_STORY_ARGS } from '../shared/js/storybook/args-utils';

export default {
component: 'cod-action-button',
title: 'Components/Atoms/ActionButton',
// 👇 Creates specific argTypes
argTypes: {
// TODO: Make this attr name and accepted
// values consistent with other action button, progress bar,
// etc. Issue #202.
buttonColor: {
options: [
'btn-outline-primary',
Expand All @@ -16,7 +19,7 @@ export default {
],
control: 'select',
},
icon: IconStory.argTypes.icon,
icon: COMMON_STORY_ARGS.icon,
title: {
control: 'text',
},
Expand Down
Loading

0 comments on commit 3d9f418

Please sign in to comment.