Skip to content

Commit

Permalink
Merge pull request #4 from samuelkurdz/test-publish
Browse files Browse the repository at this point in the history
Test publish
  • Loading branch information
Samuel Adebayo authored Apr 1, 2024
2 parents 41f092f + f851473 commit 7d8fe92
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 47 deletions.
7 changes: 7 additions & 0 deletions .changeset/itchy-swans-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@red-elements/accordion": patch
"@red-elements/tooltip": patch
"@red-elements/tabs": patch
---

updating
18 changes: 17 additions & 1 deletion apps/showcase/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@
</head>
<body>
<div id="root"></div>
<!-- <script type="module" src="./node_modules/@red-elements/primitives/dist/primitives.mjs"></script>-->
<!-- <script type="module" src="./node_modules/@red-elements/tabs/dist/tabs.mjs"></script>-->
<!-- <script type="module" src="./node_modules/@red-elements/accordion/dist/accordion.mjs"></script>-->
<!-- <script type="module" src="https://unpkg.com/@red-elements/accordion@0.0.1/dist/accordion.mjs"></script>-->

<!-- <accordion-root type="single">-->
<!-- <accordion-item value="first">-->
<!-- <accordion-trigger>acc trigger 1</accordion-trigger>-->
<!-- <accordion-content>acc content 1</accordion-content>-->
<!-- </accordion-item>-->
<!-- <accordion-item value="second">-->
<!-- <accordion-trigger>acc trigger 2</accordion-trigger>-->
<!-- <accordion-content>acc content 2</accordion-content>-->
<!-- </accordion-item>-->
<!-- <accordion-item value="third">-->
<!-- <accordion-trigger>acc trigger 3</accordion-trigger>-->
<!-- <accordion-content>acc content 3</accordion-content>-->
<!-- </accordion-item>-->
<!-- </accordion-root>-->
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions packages/accordion/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Samuel Adebayo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added packages/accordion/README.md
Empty file.
18 changes: 9 additions & 9 deletions packages/accordion/src/accordion-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AccordionRoot extends LitElement {
super.connectedCallback();

requestAnimationFrame(() => {
this.#configureAccordionChildren();
this.configureAccordionChildren();

this._provider = {
...this._provider,
Expand All @@ -58,8 +58,8 @@ export class AccordionRoot extends LitElement {
})


this.addEventListener("keydown", this.#handleKeydownEvent);
this.addEventListener("click", this.#handleClickEvent);
this.addEventListener("keydown", this.handleKeydownEvent);
this.addEventListener("click", this.handleClickEvent);
}

protected shouldUpdate(_changedProperties: PropertyValues<this>): boolean {
Expand All @@ -74,7 +74,7 @@ export class AccordionRoot extends LitElement {
return html` <slot></slot> `;
}

#configureAccordionChildren() {
configureAccordionChildren() {
const prefix = "4";
const accItems = this.querySelectorAll<HTMLElement>(accordionTags.ITEM);

Expand All @@ -101,23 +101,23 @@ export class AccordionRoot extends LitElement {
}
}

#handleKeydownEvent(event: KeyboardEvent) {
handleKeydownEvent(event: KeyboardEvent) {
if (!ACCORDION_ACTIVATION_KEYS.includes(event.key)) return;
const eventTarget = event.target as HTMLElement | null;
if (eventTarget?.localName !== "accordion-trigger") return;
event.preventDefault();
this.#activateAccordionItem(eventTarget);
this.activateAccordionItem(eventTarget);
}

#handleClickEvent(event: MouseEvent) {
handleClickEvent(event: MouseEvent) {
const eventTarget = event.target as HTMLElement;
if (eventTarget?.localName !== "accordion-trigger") return;
event.preventDefault();
// eventTarget.focus();
this.#activateAccordionItem(eventTarget);
this.activateAccordionItem(eventTarget);
}

#activateAccordionItem(eventTarget: HTMLElement) {
activateAccordionItem(eventTarget: HTMLElement) {
if (eventTarget.localName !== "accordion-trigger") return;

const accItemValue = eventTarget.parentElement?.getAttribute("value");
Expand Down
2 changes: 1 addition & 1 deletion packages/accordion/src/accordion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./accordion-root";
export * from "./accordion-item";
export * from "./accordion-trigger";
export * from "./accordion-content";
export * from "./accordion-trigger";
1 change: 0 additions & 1 deletion packages/accordion/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import {createComponent, EventName} from '@lit/react';
import * as accordion from "./accordion";


/**
* @name AccordionRoot
* @summary root container for accordions.
Expand Down
21 changes: 21 additions & 0 deletions packages/avatar/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Samuel Adebayo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added packages/avatar/README.md
Empty file.
10 changes: 8 additions & 2 deletions packages/avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
]
"dist",
"README.md",
"LICENSE"
],

"dependencies": {
"@lit/react": "^1.0.4"
}
}
3 changes: 2 additions & 1 deletion packages/avatar/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import * as avatar from "./avatar";
import {createComponent} from '@lit/react';
import * as avatar from "./avatar";

export const AvatarRoot = createComponent({
tagName: 'avatar-root',
elementClass: avatar.AvatarRoot,
react: React,
});


export const AvatarImage = createComponent({
tagName: 'avatar-image',
elementClass: avatar.AvatarImage,
Expand Down
21 changes: 21 additions & 0 deletions packages/tabs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Samuel Adebayo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added packages/tabs/README.md
Empty file.
10 changes: 8 additions & 2 deletions packages/tabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
]
"dist",
"README.md",
"LICENSE"
],

"dependencies": {
"@lit/react": "^1.0.4"
}
}
36 changes: 17 additions & 19 deletions packages/tabs/src/tabs-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class TabsList extends LitElement {
connectedCallback() {
super.connectedCallback();
this.setAttribute("role", "tablist");

this.addEventListener("keydown", this.handleKeyNavigations);
}

Expand All @@ -44,13 +43,11 @@ export class TabsList extends LitElement {
}

protected render() {
return html`
<slot></slot>
`;
return html`<slot></slot>`;
}

handleKeyNavigations(event: KeyboardEvent) {
const orientation = this._consumer.value?.orientation
handleKeyNavigations = (event: KeyboardEvent) => {
const orientation = this._consumer.value?.orientation;
const dir = getComputedStyle(this).direction; // this is also in context value

const prev = orientation === Orientation.vertical
Expand All @@ -62,17 +59,17 @@ export class TabsList extends LitElement {

// element selection
const tabTriggers = Array.from(this.children) as HTMLElement[];
const {curTriggerIdx} = this.getCurrentTabTriggerValue(tabTriggers)
const {curTriggerIdx} = this.getCurrentTabTriggerValue(tabTriggers);

let element: HTMLElement;
switch (event.key) {
case prev:
event.preventDefault();
element = this.previous(curTriggerIdx, tabTriggers);
element = this.previousElement(curTriggerIdx, tabTriggers);
break;
case next:
event.preventDefault();
element = this.next(curTriggerIdx, tabTriggers);
element = this.nextElement(curTriggerIdx, tabTriggers);
break;
case Keys.home:
element = tabTriggers[0];
Expand Down Expand Up @@ -102,25 +99,26 @@ export class TabsList extends LitElement {
return {curTriggerIdx, currTriggerVal}
}

next(selectedTabIndex: number, elements: HTMLElement[]) {
const items = elements;
const index = this.#clamp(selectedTabIndex + 1, items.length);
return items[index];
nextElement(selectedTabIndex: number, elements: HTMLElement[]) {
const index = this.clamp(selectedTabIndex + 1, elements.length);
return elements[index];
}

previous(selectedTabIndex: number, elements: HTMLElement[]) {
const items = elements;
const index = this.#clamp(selectedTabIndex - 1, items.length);
return items[index];
previousElement(selectedTabIndex: number, elements: HTMLElement[]) {
const index = this.clamp(selectedTabIndex - 1, elements.length);
return elements[index];
}

#clamp(index: number, elementsLength: number) {
private clamp(index: number, elementsLength: number) {
let returnedIndex = index;
if (index < 0) {
returnedIndex = 0;
} else if (index >= elementsLength) {
}

if (index >= elementsLength) {
returnedIndex = elementsLength - 1;
}

return returnedIndex;
}
}
7 changes: 3 additions & 4 deletions packages/tabs/src/tabs-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ export class TabsRoot extends LitElement {
orientation: this.orientation ?? "horizontal",
value: this.defaultValue?.trim().length ? this.defaultValue : defaultSelected!
};
});


this.addEventListener("pointerdown", this.handlePointerDownEvent);
this.addEventListener("keynavigation", this.handleKeyNavigationEvent);
this.addEventListener("pointerdown", this.handlePointerDownEvent);
this.addEventListener("keynavigation", this.handleKeyNavigationEvent);
});
}

disconnectedCallback() {
Expand Down
1 change: 1 addition & 0 deletions packages/tabs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"exclude": ["src/**/*.stories.ts"],
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"outDir": "dist"
}
}
21 changes: 21 additions & 0 deletions packages/tooltip/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Samuel Adebayo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added packages/tooltip/README.md
Empty file.
10 changes: 8 additions & 2 deletions packages/tooltip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
]
"dist",
"README.md",
"LICENSE"
],

"dependencies": {
"@lit/react": "^1.0.4"
}
}
18 changes: 15 additions & 3 deletions pnpm-lock.yaml

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

Loading

0 comments on commit 7d8fe92

Please sign in to comment.