Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup.Spinner #218

Open
wants to merge 30 commits into
base: 2.0.0-alpha1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
627f6a7
Create V2 table
maxatdetroit Apr 26, 2024
72fe6ca
Fix lints and formatting
maxatdetroit Apr 29, 2024
b5aa2c3
Merge branch '2.0.0-alpha1' into issue.199
maxatdetroit Apr 29, 2024
e90580c
Added cod-button and close functionality
KaeTheDev Apr 29, 2024
4d88ea5
Use common story arguments
maxatdetroit Apr 30, 2024
9761f53
Formatting
maxatdetroit Apr 30, 2024
e1becdf
Merge pull request #207 from CityOfDetroit/issue.199
jedgar1mx May 1, 2024
882e029
Fix size arguments
maxatdetroit May 1, 2024
66e117b
Removed old colde from Alert.js and .stories file. Add isClosed as a …
KaeTheDev May 1, 2024
2d7a391
Merge pull request #210 from CityOfDetroit/story.utils
jedgar1mx May 2, 2024
1ee88d0
Changed name of boolean to isOpen
KaeTheDev May 2, 2024
f0196ea
Added another Template.bind for the Alert Close
KaeTheDev May 2, 2024
b375a04
Added template.bind for Alert Close and conditional code for checking…
KaeTheDev May 2, 2024
b7e9edb
Changed is-open attribute to closeable
KaeTheDev May 3, 2024
b118bbc
Removed extra template.bind for closeable alert
KaeTheDev May 3, 2024
3184f7b
Added some functionality and the close button
KaeTheDev May 3, 2024
9e9c267
Fixed prettier issues in 3 files
KaeTheDev May 3, 2024
4ae18ab
Removed code from Alert.js that was not doing anything
KaeTheDev May 6, 2024
efa023a
Got close button responding to closeable variable using a conditional…
KaeTheDev May 6, 2024
52ba7db
Merge branch 'dev' into fix.issue.1319
KaeTheDev May 6, 2024
76f7f39
Fixed prettier issues in 2 files
KaeTheDev May 6, 2024
575dd34
Reverted Alert.js file
KaeTheDev May 6, 2024
b8c03fc
Fixed prettier issues in 1 file
KaeTheDev May 6, 2024
f6adad0
Attempt to revert back
KaeTheDev May 6, 2024
16d0b78
Attempt to fix botched DEV merge and fixed prettier issues in 2 files
KaeTheDev May 6, 2024
9a69a02
Merge pull request #208 from CityOfDetroit/fix.issue.1319
jedgar1mx May 8, 2024
dd2e0d9
Update production build
maxatdetroit May 14, 2024
80d8b63
Update changelog
maxatdetroit May 14, 2024
5813842
Merge pull request #215 from CityOfDetroit/v1.0.21
maxatdetroit May 14, 2024
cbff73b
updtates naming conventions removing "data-" from attribute names
SBBlee May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}
8 changes: 4 additions & 4 deletions src/components/atoms/Spinner/Spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default class Image extends HTMLElement {
this.shadowRoot.appendChild(spinnerStyles);
// image attributes

const spinnerType = this.getAttribute('data-type');
const spinnerType = this.getAttribute('type');

const spinnerSize = this.getAttribute('data-size');
const spinnerSize = this.getAttribute('size');

const backgroundColor = this.getAttribute('data-background-color');
const backgroundColor = this.getAttribute('background-color');

const displayType = this.getAttribute('data-display-type');
const displayType = this.getAttribute('display-type');
let spinnerSizeClass;

// TODO: Fix old ESLint errors - see issue #1099
Expand Down
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 };
Loading
Loading