feat: twind plugin (#513)
This adds a first-party twind plugin to use twind for styling.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||
return (
|
||||
@@ -9,7 +8,7 @@ export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||
touchAction: "manipulation",
|
||||
}}
|
||||
{...props}
|
||||
class={tw`p-3 border border-transparent rounded-full text-white bg-green(500 hover:600) focus:(outline-none ring(2 offset-2 green-500)) disabled:(bg-green-200 cursor-default)`}
|
||||
class="p-3 border border-transparent rounded-full text-white bg-green(500 hover:600) focus:(outline-none ring(2 offset-2 green-500)) disabled:(bg-green-200 cursor-default)}"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { apply, tw } from "@twind";
|
||||
|
||||
import {
|
||||
CATEGORIES,
|
||||
@@ -10,7 +9,7 @@ import {
|
||||
|
||||
export default function DocsSidebar(props: { path: string }) {
|
||||
return (
|
||||
<ol class={tw`list-decimal list-inside font-semibold` + " nested"}>
|
||||
<ol class="list-decimal list-inside font-semibold nested">
|
||||
{CATEGORIES.map((category) => (
|
||||
<SidebarCategory path={props.path} category={category} />
|
||||
))}
|
||||
@@ -18,24 +17,22 @@ export default function DocsSidebar(props: { path: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
const link = apply`text(gray-900 hover:gray-600)`;
|
||||
const linkActive = apply`text(green-600 hover:green-500)`;
|
||||
const link = "text(gray-900 hover:gray-600)";
|
||||
const linkActive = "text(green-600 hover:green-500)";
|
||||
|
||||
export function SidebarCategory(props: {
|
||||
path: string;
|
||||
category: TableOfContentsCategory;
|
||||
}) {
|
||||
const outerItem = tw`my-2 block`;
|
||||
const innerList = tw`pl-4 list-decimal` + " nested";
|
||||
|
||||
const { title, href, entries } = props.category;
|
||||
const outerLink = tw`${href == props.path ? linkActive : link} font-bold`;
|
||||
|
||||
const outerLink = `${href == props.path ? linkActive : link} font-bold`;
|
||||
|
||||
return (
|
||||
<li class={outerItem}>
|
||||
<li class="my-2 block">
|
||||
<a href={href} class={outerLink}>{title}</a>
|
||||
{entries.length > 0 && (
|
||||
<ol class={innerList}>
|
||||
<ol class="pl-4 list-decimal nested">
|
||||
{entries.map((entry) => (
|
||||
<SidebarEntry path={props.path} entry={entry} />
|
||||
))}
|
||||
@@ -49,12 +46,12 @@ export function SidebarEntry(props: {
|
||||
path: string;
|
||||
entry: TableOfContentsCategoryEntry;
|
||||
}) {
|
||||
const innerItem = tw`my-0.5`;
|
||||
|
||||
const { title, href } = props.entry;
|
||||
const innerLink = tw`${href == props.path ? linkActive : link} font-normal`;
|
||||
|
||||
const innerLink = `${href == props.path ? linkActive : link} font-normal`;
|
||||
|
||||
return (
|
||||
<li class={innerItem}>
|
||||
<li class="my-0.5">
|
||||
<a href={href} class={innerLink}>{title}</a>
|
||||
</li>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
const LINKS = [
|
||||
{
|
||||
@@ -18,23 +17,17 @@ const LINKS = [
|
||||
];
|
||||
|
||||
export default function Footer() {
|
||||
const footer =
|
||||
tw`border(t-2 gray-200) bg-gray-100 h-32 flex flex-col gap-4 justify-center`;
|
||||
const inner =
|
||||
tw`mx-auto max-w-screen-lg flex items-center justify-center gap-8`;
|
||||
const linkStyle = tw`text-gray-600 hover:underline`;
|
||||
const copyright = tw`text(gray-600 center)`;
|
||||
return (
|
||||
<footer class={footer}>
|
||||
<div class={inner}>
|
||||
<footer class="border(t-2 gray-200) bg-gray-100 h-32 flex flex-col gap-4 justify-center">
|
||||
<div class="mx-auto max-w-screen-lg flex items-center justify-center gap-8">
|
||||
{LINKS.map((link) => (
|
||||
<a href={link.href} class={linkStyle}>
|
||||
<a href={link.href} class="text-gray-600 hover:underline">
|
||||
{link.title}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<div class={copyright}>
|
||||
<span>© {new Date().getFullYear()} the Fresh authors</span>
|
||||
<div class="text(gray-600 center)">
|
||||
<span>© {new Date().getFullYear()} the fresh authors</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
export function IconMinus() {
|
||||
return (
|
||||
<svg
|
||||
class={tw`h-6 w-6`}
|
||||
class="h-6 w-6"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -25,7 +24,7 @@ export function IconMinus() {
|
||||
export function IconPlus() {
|
||||
return (
|
||||
<svg
|
||||
class={tw`h-6 w-6`}
|
||||
class="h-6 w-6"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
export default function NavigationBar(props: { active: string }) {
|
||||
const items = [
|
||||
@@ -15,13 +14,13 @@ export default function NavigationBar(props: { active: string }) {
|
||||
];
|
||||
|
||||
return (
|
||||
<nav class={tw`bg-green-200 py-2`}>
|
||||
<ul class={tw`flex justify-center gap-8 mx-4`}>
|
||||
<nav class="bg-green-200 py-2">
|
||||
<ul class="flex justify-center gap-8 mx-4">
|
||||
{items.map((item) => (
|
||||
<li>
|
||||
<a
|
||||
href={item.href}
|
||||
class={tw`text-gray-600 hover:underline ${
|
||||
class={`text-gray-600 hover:underline ${
|
||||
props.active == item.href ? "font-bold" : ""
|
||||
}`}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user