Skip to content

Commit a2a17fa

Browse files
Abstract theme components to theme folder (#7)
* Move components to theme * Abstract underlying page layout * Fix types on web components * Move search plugin into theme * Remove console.log * Move remark plugin config into theme * Move post components out of theme These are very site-specific components, so they shouldn't exist in the theme.
1 parent cb888a8 commit a2a17fa

File tree

170 files changed

+293
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+293
-231
lines changed

astro.config.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import sitemap from "@astrojs/sitemap";
22
import { defineConfig, envField } from "astro/config";
3-
import { remarkCustomDirectives } from "./lib/remarkCustomDirectives";
4-
import { deltaTheme } from "./lib/delta-theme";
3+
import { deltaTheme, remarkPlugins } from "./lib/delta-theme";
54

65
// https://astro.build/config
76
export default defineConfig({
@@ -14,7 +13,7 @@ export default defineConfig({
1413
validateSecrets: true,
1514
},
1615
markdown: {
17-
remarkPlugins: [...remarkCustomDirectives],
16+
remarkPlugins,
1817
},
1918
image: {
2019
domains: [],
File renamed without changes.
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,24 @@ const { label, toggleClassName } = Astro.props;
2222
</dropdown-container>
2323
<script>
2424
class Dropdown extends HTMLElement {
25-
connectedCallback() {
26-
const button = this.querySelector("[data-toggle]");
27-
const container = this.querySelector("[data-container]");
25+
#button: HTMLButtonElement | null = null;
26+
#container: HTMLElement | null = null;
27+
28+
constructor() {
29+
super();
2830

29-
button?.addEventListener("click", () => {
30-
if (button.getAttribute("aria-expanded") === "true") {
31-
button.setAttribute("aria-expanded", "false");
32-
container?.classList.replace("block", "hidden");
31+
this.#button = this.querySelector("[data-toggle]");
32+
this.#container = this.querySelector("[data-container]");
33+
}
34+
35+
connectedCallback() {
36+
this.#button?.addEventListener("click", () => {
37+
if (this.#button?.getAttribute("aria-expanded") === "true") {
38+
this.#button?.setAttribute("aria-expanded", "false");
39+
this.#container?.classList.replace("block", "hidden");
3340
} else {
34-
button.setAttribute("aria-expanded", "true");
35-
container?.classList.replace("hidden", "block");
41+
this.#button?.setAttribute("aria-expanded", "true");
42+
this.#container?.classList.replace("hidden", "block");
3643
}
3744
});
3845
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { site } from "@config/site";
33
import type { MenuItem } from "./Menu";
44
import { Menu } from "./Menu";
5-
import Grid from "@components/Grid.astro";
6-
import Section from "@components/Section.astro";
7-
import Typography from "@components/Typography.astro";
5+
import Grid from "./Grid.astro";
6+
import Section from "./Section.astro";
7+
import Typography from "./Typography.astro";
88
import DeltaLogo from "./assets/delta-lake-logo.svg";
99
import LinuxFoundationLogo from "./assets/the-linux-foundation-projects.svg";
1010
import { Image } from "astro:assets";

src/components/FormField.astro renamed to lib/delta-theme/components/FormField.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import clsx from "clsx";
33
import type { ComponentProps } from "astro/types";
4-
import Icon from "@components/Icon.astro";
4+
import Icon from "./Icon.astro";
55
66
type IconType = ComponentProps<typeof Icon>["icon"];
77

src/components/Header/Header.astro renamed to lib/delta-theme/components/Header/Header.astro

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
import { site } from "@config/site";
3-
import Section from "@components/Section.astro";
4-
import Icon from "@components/Icon.astro";
3+
import Section from "../Section.astro";
4+
import Icon from "../Icon.astro";
55
import { Menu } from "../Menu";
66
import HeaderButton from "./HeaderButton.astro";
77
import Search from "./Search.astro";
8-
import DeltaLogo from "@components/assets/delta-lake-logo.svg";
9-
import LinuxFoundationLogo from "@components/assets/the-linux-foundation-projects.svg";
8+
import DeltaLogo from "../assets/delta-lake-logo.svg";
9+
import LinuxFoundationLogo from "../assets/the-linux-foundation-projects.svg";
1010
import { Image } from "astro:assets";
1111
---
1212

@@ -136,18 +136,20 @@ import { Image } from "astro:assets";
136136
}
137137

138138
connectedCallback() {
139-
this.#openButton.addEventListener("click", () => this.#toggleMenu());
140-
this.#closeButton.addEventListener("click", () => this.#toggleMenu());
141-
this.#backdrop.addEventListener("click", () => this.#toggleMenu());
139+
this.#openButton?.addEventListener("click", () => this.#toggleMenu());
140+
this.#closeButton?.addEventListener("click", () => this.#toggleMenu());
141+
this.#backdrop?.addEventListener("click", () => this.#toggleMenu());
142142
}
143143

144144
#toggleMenu() {
145-
const state = this.#menuWrapper.dataset.toggled;
145+
if (this.#menuWrapper) {
146+
const state = this.#menuWrapper.dataset.toggled;
146147

147-
if (state === "true") {
148-
this.#menuWrapper.dataset.toggled = "false";
149-
} else {
150-
this.#menuWrapper.dataset.toggled = "true";
148+
if (state === "true") {
149+
this.#menuWrapper.dataset.toggled = "false";
150+
} else {
151+
this.#menuWrapper.dataset.toggled = "true";
152+
}
151153
}
152154
}
153155
}
File renamed without changes.

src/components/Header/Search.astro renamed to lib/delta-theme/components/Header/Search.astro

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
import "@pagefind/default-ui/css/ui.css";
3-
import Icon from "@components/Icon.astro";
4-
import Modal from "@components/Modal.astro";
5-
import Typography from "@components/Typography.astro";
3+
import Icon from "../Icon.astro";
4+
import Modal from "../Modal.astro";
5+
import Typography from "../Typography.astro";
66
import HeaderButton from "./HeaderButton.astro";
77
---
88

@@ -145,31 +145,31 @@ import HeaderButton from "./HeaderButton.astro";
145145
</script>
146146
<script>
147147
class SearchContainer extends HTMLElement {
148-
isModalOpen() {
148+
#modal: HTMLDialogElement | null = null;
149+
#button: HTMLButtonElement | null = null;
150+
151+
constructor() {
152+
super();
153+
149154
const modalId = this.dataset.modalId;
150-
const modal = this.querySelector(`#${modalId}`);
155+
this.#modal = this.querySelector(`#${modalId}`);
156+
this.#button = this.querySelector(".header-open-search-modal");
157+
}
151158

152-
return modal.open;
159+
isModalOpen() {
160+
return this.#modal?.open;
153161
}
154162

155163
openModal() {
156-
const modalId = this.dataset.modalId;
157-
const modal = this.querySelector(`#${modalId}`);
158-
159-
modal.showModal();
164+
this.#modal?.showModal();
160165
}
161166

162167
closeModal() {
163-
const modalId = this.dataset.modalId;
164-
const modal = this.querySelector(`#${modalId}`);
165-
166-
modal.close();
168+
this.#modal?.close();
167169
}
168170

169171
connectedCallback() {
170-
const button = this.querySelector(".header-open-search-modal");
171-
172-
button.addEventListener("click", () => {
172+
this.#button?.addEventListener("click", () => {
173173
this.openModal();
174174
});
175175

0 commit comments

Comments
 (0)