Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #91 from doras-to/staging
Browse files Browse the repository at this point in the history
Staging added doras icons to buttons
  • Loading branch information
trent-gezel committed Dec 27, 2023
2 parents d268af0 + 4a584cb commit 8de8c64
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/components/linkspage/LinksButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Links } from "@/server_types";
import React from "react";

import * as tabler from "@tabler/icons-react";
import DorasIcons from "@/lib/DorasIcons";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, DialogFooter } from "@/components/ui/dialog";
import { Button } from "../ui/button";
interface Props {
Expand All @@ -20,6 +21,23 @@ function ClickButton(id: any, link: any) {
}

const LinksButton: React.FC<Props> = ({ id, text, href, bgColor, textColor, Icon, link, verifiedData, className, style }) => {
if (Icon.startsWith("Icon")) {
//@ts-ignore
Icon = (<div className={"absolute left-4 top-1/2 transform -translate-y-1/2"}>{React.createElement(tabler[link.icon], { size: 20 })}</div>)
} else if (Icon.startsWith("Doras")) {
let icon_item = DorasIcons.find(i => i.value == link.icon);
if (icon_item) {
//@ts-ignore
let img: string;
if (style.color == "white") {
img = icon_item.light
} else {
img = icon_item.dark
}
//@ts-ignore
Icon = (<img src={img} className={"absolute left-4 top-1/2 transform -translate-y-1/2"} style={{ width: 20, height: 20 }} />)
}
}
const colorClasses = {
bgColor: `bg-${bgColor}`,
textColor: `text-${textColor} dark:text-${textColor}`
Expand All @@ -35,7 +53,8 @@ const LinksButton: React.FC<Props> = ({ id, text, href, bgColor, textColor, Icon
return (
<a className="w-full" href={href} target="_blank" onClick={() => ClickButton(id, link)}>
<button className={`w-full px-1 py-3 text-xl ${className} relative`} style={style}>
<i className={"absolute left-4 top-1/2 transform -translate-y-1/2 " + Icon}></i>
{/* <i className={"absolute left-4 top-1/2 transform -translate-y-1/2 " + Icon}></i> */}
{Icon}
<span className={`block w-full text-center px-6 ${colorClasses.textColor} font-bold`}>{text}</span>
</button>
</a>
Expand Down Expand Up @@ -63,7 +82,8 @@ const LinksButtonDialog: React.FC<PropsDialog> = ({ id, title, className, Icon,
<Dialog>
<DialogTrigger asChild>
<button className={`w-full px-1 py-3 text-xl ${className} relative`} style={style}>
<i className={"absolute left-4 top-1/2 transform -translate-y-1/2 " + Icon}></i>
{/* <i className={"absolute left-4 top-1/2 transform -translate-y-1/2 " + Icon}></i> */}
{Icon}
<span className={`block w-full text-center px-6 ${colorClasses.textColor} font-bold`}>{text}</span>
</button>
</DialogTrigger>
Expand Down
6 changes: 6 additions & 0 deletions src/lib/DorasIcons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const DorasIcons = [{
value: "DorasIcon",
dark: "https://cdn.doras.to/doras/icons/dark/doras.webp",
light: "https://cdn.doras.to/doras/icons/light/doras.webp"
}];
export default DorasIcons;

0 comments on commit 8de8c64

Please sign in to comment.