-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
269bcb8
commit a853fde
Showing
1 changed file
with
12 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { BaseColors } from "@/types/app"; | ||
import { colorHelper } from "../colorHelper"; | ||
|
||
async function generateFigmaUrlToken(baseColors: Omit<BaseColors, "gray">) { | ||
const url = await fetch("/api/figma-plugin", { | ||
const { data, error } = await fetch("/api/v1/figma-plugin", { | ||
body: JSON.stringify({ | ||
baseColors, | ||
}), | ||
method: "POST", | ||
body: JSON.stringify({ baseColors }), | ||
}).then((res) => res.text()); | ||
return url; | ||
}).then((res) => res.json()); | ||
const hexColors = Object.values(baseColors).map((color) => | ||
colorHelper.toHex(color), | ||
); | ||
return `${process.env.NEXT_PUBLIC_URL}/?token=${ | ||
data.token | ||
}&colors=${encodeURIComponent(hexColors.join(","))}`; | ||
} | ||
|
||
export default generateFigmaUrlToken; |