site/quartz/components/Btn8831.tsx

37 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-10-14 06:49:37 +00:00
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
2024-10-14 07:15:35 +00:00
import style from "./styles/buttons8831.scss"
2024-10-14 06:49:37 +00:00
import { useEffect, useState } from "preact/hooks"
// Import the JSON data
2024-10-14 07:10:49 +00:00
import buttonsData from "./buttons.json"
2024-10-14 07:09:28 +00:00
export default (() => {
// Define the component
const Btn8831: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
// Since the data is static, you can directly use buttonsData
const [buttons, setButtons] = useState(buttonsData)
// Optional: If you need to perform any data manipulation or sorting, you can do it here
// For example, if buttonsData isn't sorted, but you need to sort it:
// useEffect(() => {
// const sortedButtons = [...buttonsData].sort(/* your sorting function */);
// setButtons(sortedButtons);
// }, []);
return (
<div class={`btn8831-container ${displayClass ?? ""}`}>
{buttons.map((button, index) => (
<a href={button.url} key={index}>
<img src={button.image} alt={button.alt} />
</a>
))}
</div>
)
2024-10-14 07:08:15 +00:00
}
2024-10-14 06:49:37 +00:00
2024-10-14 07:09:28 +00:00
// Combine base styles with custom styles
2024-10-14 07:15:35 +00:00
Btn8831.css = style
2024-10-14 07:09:28 +00:00
return Btn8831
})() satisfies QuartzComponentConstructor