Skip to content

Commit

Permalink
🎨 Update TWMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Mafrans committed Feb 7, 2022
1 parent 87fd111 commit 8207345
Show file tree
Hide file tree
Showing 7 changed files with 1,484 additions and 27 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "galex"
"extends": "galex",
"rules": {
"@typescript-eslint/explicit-member-accessibility": "off"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"dev": "vite dev",
"start": "vite --host",
"build": "vite build",
"lint": "eslint src"
"lint": "eslint src --fix"
},
"devDependencies": {
"autoprefixer": "^10.4.2",
"eslint": "^8.8.0",
"eslint-config-galex": "^3.6.3",
"tailwindcss": "^3.0.18",
"typescript": "^4.5.5",
"vite": "^2.7.13"
Expand Down
5 changes: 3 additions & 2 deletions src/@types/Mixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LitElement } from "lit";
import type { LitElement } from "lit";

declare global {
export type LitMixin<T = {}> = new (...args: any[]) => T & LitElement;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export type LitMixin<T = unknown> = new (...args: any[]) => T & LitElement;
}
6 changes: 4 additions & 2 deletions src/components/HelloWorld.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { TemplateResult } from "lit";
import { html, LitElement } from "lit";
import { customElement } from "lit/decorators.js";
import { TW } from "../util/TWMixin";

import { TW } from "../util/TailwindMixin";

@customElement("x-hello-world")
export class HelloWorld extends TW(LitElement) {
render() {
render(): TemplateResult {
return html` <h1 class="text-2xl">Hello world!</h1> `;
}
}
6 changes: 4 additions & 2 deletions src/pages/IndexPage.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Components
import type { TemplateResult } from "lit";
import { html, LitElement } from "lit";
import { customElement } from "lit/decorators.js";

import "../components/HelloWorld";
import "../styles/main.css";
import { TW } from "../util/TWMixin";
import { TW } from "../util/TailwindMixin";

@customElement("x-index-page")
export class IndexPage extends TW(LitElement) {
render() {
render(): TemplateResult {
return html`
<div class="container">
<x-hello-world></x-hello-world>
Expand Down
4 changes: 2 additions & 2 deletions src/util/TWMixin.ts → src/util/TailwindMixin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const TW = <T extends LitMixin>(superClass: T) =>
export const TW = <T extends LitMixin>(superClass: T): T =>
class extends superClass {
connectedCallback() {
super.connectedCallback();
Expand All @@ -8,6 +8,6 @@ export const TW = <T extends LitMixin>(superClass: T) =>
link.type = "text/css";
link.href = new URL("../styles/main.css", import.meta.url).href;

this.shadowRoot.appendChild(link);
this.shadowRoot.append(link);
}
};
Loading

0 comments on commit 8207345

Please sign in to comment.