Skip to content

Commit

Permalink
fix!: Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell committed Oct 17, 2023
1 parent 011b781 commit 3f3e7b5
Show file tree
Hide file tree
Showing 31 changed files with 863 additions and 844 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm install
- name: Lint
run: npm run -s pretest
Expand Down
32 changes: 16 additions & 16 deletions fixtures/fontawesome.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
@import '/node_modules/@fortawesome/fontawesome-free/css/solid.css';

@font-face {
font-family: 'global-font';
font-style: normal;
font-weight: 400;
font-display: auto;
src: url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.eot");
src: url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2") format("woff2"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff") format("woff"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.ttf") format("truetype"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.svg#fontawesome") format("svg");
font-family: 'global-font';
font-style: normal;
font-weight: 400;
font-display: auto;
src: url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.eot");
src: url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2") format("woff2"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff") format("woff"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.ttf") format("truetype"), url("/node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.svg#fontawesome") format("svg");
}

/* Using fontawesome globally is an attempt to normalize font on different platforms */
* {
font-family: 'global-font';
font-family: 'global-font';
}

html, body {
display: inline-block!important;
margin: 0;
width: -moz-fit-content;
display: inline-block!important;
margin: 0;
width: -moz-fit-content;
}

div {
height: 400px;
width: 40rem;
display: flex;
background: #eee;
display: flex;
flex-direction: column;
height: 400px;
width: 40rem;
display: flex;
background: #eee;
display: flex;
flex-direction: column;
}
28 changes: 14 additions & 14 deletions fixtures/nav-empty.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<html>
<head>
<title>&lt;nav-menu&gt; empty test</title>
<script type="module" src="nav-menu.js"></script>
<link rel="stylesheet" href="fontawesome.css">
</head>
<body>
<div id="container">
<nav-menu id="test">
<nav-section title="">
<nav-item title="" hidden></nav-item>
</nav-section>
</nav-menu>
</div>
</body>
<head>
<title>&lt;nav-menu&gt; empty test</title>
<script type="module" src="nav-menu.js"></script>
<link rel="stylesheet" href="fontawesome.css">
</head>
<body>
<div id="container">
<nav-menu id="test">
<nav-section title="">
<nav-item title="" hidden></nav-item>
</nav-section>
</nav-menu>
</div>
</body>
</html>
36 changes: 18 additions & 18 deletions fixtures/nav-menu.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<html>
<head>
<title>&lt;nav-menu&gt; test</title>
<script type="module" src="nav-menu.js"></script>
<link rel="stylesheet" href="fontawesome.css">
</head>
<body>
<div>
<nav-menu id="test">
<nav-section id="section1" title="">
<nav-item id="item1a" title="" href="nav-menu.html"></nav-item>
</nav-section>
<nav-section title="">
<nav-item id="item2a" title=""></nav-item>
<nav-item title=""></nav-item>
</nav-section>
</nav-menu>
</div>
</body>
<head>
<title>&lt;nav-menu&gt; test</title>
<script type="module" src="nav-menu.js"></script>
<link rel="stylesheet" href="fontawesome.css">
</head>
<body>
<div>
<nav-menu id="test">
<nav-section id="section1" title="">
<nav-item id="item1a" title="" href="nav-menu.html"></nav-item>
</nav-section>
<nav-section title="">
<nav-item id="item2a" title=""></nav-item>
<nav-item title=""></nav-item>
</nav-section>
</nav-menu>
</div>
</body>
</html>
34 changes: 17 additions & 17 deletions fixtures/nav-no-hrefs.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<html>
<head>
<title>&lt;nav-menu&gt; no href test</title>
<script type="module" src="nav-menu.js"></script>
<link rel="stylesheet" href="fontawesome.css">
</head>
<body>
<div>
<nav-menu id="test">
<nav-section title="">
<nav-item title="" href="nav-none1.html"></nav-item>
</nav-section>
<nav-section title="">
<nav-item title="" href="nav-none2.html"></nav-item>
</nav-section>
</nav-menu>
</div>
</body>
<head>
<title>&lt;nav-menu&gt; no href test</title>
<script type="module" src="nav-menu.js"></script>
<link rel="stylesheet" href="fontawesome.css">
</head>
<body>
<div>
<nav-menu id="test">
<nav-section title="">
<nav-item title="" href="nav-none1.html"></nav-item>
</nav-section>
<nav-section title="">
<nav-item title="" href="nav-none2.html"></nav-item>
</nav-section>
</nav-menu>
</div>
</body>
</html>
104 changes: 52 additions & 52 deletions nav-item.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
import ShadowElement, {html, template, css, adoptedStyleSheets, define, reflectBooleanProperties, reflectStringProperties} from '@cfware/shadow-element';

class NavItem extends ShadowElement {
constructor() {
super();

const observer = new MutationObserver(() => this.dispatchEvent(new Event('hiddenchange')));
observer.observe(this, {
attributes: true,
attributeFilter: ['hidden']
});
}

get pathname() {
return new URL(this.href, document.baseURI).pathname;
}

static [adoptedStyleSheets] = [
css`
a {
display: block;
position: relative;
margin-left: .85rem;
padding: .83rem .95rem .83rem .85rem;
color: #000a;
text-decoration: none;
line-height: 1;
border-left: .2rem solid transparent;
}
a:hover {
color: #005d90;
}
a:focus {
background-color: #8881;
}
a:active {
background-color: #0001;
}
:host(:not(:first-child)) a {
border-top: 1px solid #8882;
}
:host([active]) a {
border-left-color: unset;
}
`
];

get [template]() {
return html`<a href=${this.href}>${this.title}</a>`;
}
constructor() {
super();

const observer = new MutationObserver(() => this.dispatchEvent(new Event('hiddenchange')));
observer.observe(this, {
attributes: true,
attributeFilter: ['hidden']
});
}

get pathname() {
return new URL(this.href, document.baseURI).pathname;
}

static [adoptedStyleSheets] = [
css`
a {
display: block;
position: relative;
margin-left: .85rem;
padding: .83rem .95rem .83rem .85rem;
color: #000a;
text-decoration: none;
line-height: 1;
border-left: .2rem solid transparent;
}
a:hover {
color: #005d90;
}
a:focus {
background-color: #8881;
}
a:active {
background-color: #0001;
}
:host(:not(:first-child)) a {
border-top: 1px solid #8882;
}
:host([active]) a {
border-left-color: unset;
}
`
];

get [template]() {
return html`<a href=${this.href}>${this.title}</a>`;
}
}

reflectBooleanProperties(NavItem, ['active']);
Expand Down
84 changes: 42 additions & 42 deletions nav-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@ import './nav-section.js';
import './nav-item.js';

class NavMenu extends ShadowElement {
update() {
const {pathname} = window.location;
const items = [...this.querySelectorAll('nav-item')];
const matches = items
.filter(item => pathname.startsWith(item.pathname))
.sort((a, b) => b.pathname.length - a.pathname.length);

for (const item of items) {
item.active = item === matches[0];
}

const sections = [...this.querySelectorAll('nav-section:not([hidden])')];
if (sections.length === 0) {
return;
}

const activeSections = sections.filter(section => {
if (!section.active) {
section.active = section.querySelectorAll('nav-item[active]:not([hidden])').length > 0;
}

return section.active;
});

if (matches.length === 0 || activeSections.length === 0) {
sections[0].active = true;
}
}

static [adoptedStyleSheets] = [
css`
:host {
width: 15rem;
font-weight: 400;
user-select: none;
}
`
];

get [template]() {
return html`<slot />`;
}
update() {
const {pathname} = window.location;
const items = [...this.querySelectorAll('nav-item')];
const matches = items
.filter(item => pathname.startsWith(item.pathname))
.sort((a, b) => b.pathname.length - a.pathname.length);

for (const item of items) {
item.active = item === matches[0];
}

const sections = [...this.querySelectorAll('nav-section:not([hidden])')];
if (sections.length === 0) {
return;
}

const activeSections = sections.filter(section => {
if (!section.active) {
section.active = section.querySelectorAll('nav-item[active]:not([hidden])').length > 0;
}

return section.active;
});

if (matches.length === 0 || activeSections.length === 0) {
sections[0].active = true;
}
}

static [adoptedStyleSheets] = [
css`
:host {
width: 15rem;
font-weight: 400;
user-select: none;
}
`
];

get [template]() {
return html`<slot />`;
}
}

NavMenu[define]('nav-menu');
Loading

0 comments on commit 3f3e7b5

Please sign in to comment.