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 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) => {
|
2024-10-14 10:32:16 +00:00
|
|
|
// Group buttons by type
|
|
|
|
const groupedButtons = groupButtonsByType(buttonsData)
|
2024-10-14 07:09:28 +00:00
|
|
|
|
2024-10-14 10:32:16 +00:00
|
|
|
// Define the order of types
|
|
|
|
const typeOrder = ["misc", "friend", "standard"]
|
2024-10-14 07:09:28 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div class={`btn8831-container ${displayClass ?? ""}`}>
|
2024-10-14 10:32:16 +00:00
|
|
|
{typeOrder.map((type, index) => {
|
|
|
|
const buttons = groupedButtons[type]
|
|
|
|
if (buttons && buttons.length > 0) {
|
|
|
|
return (
|
|
|
|
<div key={type}>
|
|
|
|
{/* Render buttons of the current type */}
|
|
|
|
<div class="button-group">
|
|
|
|
{buttons.map((button, idx) => (
|
|
|
|
<a href={button.url} key={idx}>
|
|
|
|
<img src={button.image} alt={button.alt} title={button.title} />
|
|
|
|
</a>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
{/* Add a horizontal line after the group except for the last one */}
|
|
|
|
{index < typeOrder.length - 1 && <hr />}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
})}
|
|
|
|
{/* Include the iframe if needed */}
|
|
|
|
<iframe
|
|
|
|
src="//incr.easrng.net/badge?key=changeme"
|
|
|
|
style="background: url(//incr.easrng.net/bg.gif)"
|
|
|
|
title="increment badge"
|
|
|
|
width="88"
|
|
|
|
height="31"
|
|
|
|
frameborder="0"
|
|
|
|
></iframe>
|
2024-10-14 07:09:28 +00:00
|
|
|
</div>
|
|
|
|
)
|
2024-10-14 07:08:15 +00:00
|
|
|
}
|
2024-10-14 06:49:37 +00:00
|
|
|
|
2024-10-14 10:32:16 +00:00
|
|
|
// Function to group buttons by type
|
|
|
|
function groupButtonsByType(buttons) {
|
|
|
|
const groups = {
|
|
|
|
misc: [],
|
|
|
|
friend: [],
|
|
|
|
standard: [],
|
|
|
|
}
|
|
|
|
|
|
|
|
buttons.forEach((button) => {
|
|
|
|
let type = button.type?.toLowerCase() || "standard"
|
|
|
|
if (type === "fren") type = "friend"
|
|
|
|
if (!groups[type]) type = "standard" // Default to 'standard' if type is unrecognized
|
|
|
|
groups[type].push(button)
|
|
|
|
})
|
|
|
|
|
|
|
|
return groups
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use the existing style and add any additional styles if necessary
|
2024-10-14 07:15:35 +00:00
|
|
|
Btn8831.css = style
|
2024-10-14 07:09:28 +00:00
|
|
|
|
|
|
|
return Btn8831
|
|
|
|
})() satisfies QuartzComponentConstructor
|