Skip to content

Commit

Permalink
feat: add text tokens (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlnf authored Jun 3, 2024
1 parent 139b729 commit 3b143e2
Show file tree
Hide file tree
Showing 41 changed files with 371 additions and 350 deletions.
4 changes: 2 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.4",
"private": true,
"scripts": {
"format": "prettier 'src/**/*.ts' --write",
"format:check": "prettier 'src/**/*.ts' --check",
"format": "prettier 'src/**/*.{ts,tsx}' --write",
"format:check": "prettier 'src/**/*.{ts,tsx}' --check",
"dev": "next dev",
"build": "next build",
"build:prod": "cross-env CI=true next build",
Expand Down
8 changes: 4 additions & 4 deletions apps/docs/src/app/[...slug]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { notFound } from "next/navigation";
import * as documents from "@/lib/documents/documents";
import { SideNavigationConnected } from "@/components/navigation/side-navigation-connected";
import { notFound } from 'next/navigation';
import * as documents from '@/lib/documents/documents';
import { SideNavigationConnected } from '@/components/navigation/side-navigation-connected';

export async function generateStaticParams() {
return documents.getAll().map((document) => ({
slug: document.slug.split("/"),
slug: document.slug.split('/'),
}));
}

Expand Down
12 changes: 6 additions & 6 deletions apps/docs/src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { notFound } from "next/navigation";
import { Mdx } from "@/components/document/mdx";
import * as documents from "@/lib/documents/documents";
import { DocumentStatus } from "@/components/document/document-status";
import { notFound } from 'next/navigation';
import { Mdx } from '@/components/document/mdx';
import * as documents from '@/lib/documents/documents';
import { DocumentStatus } from '@/components/document/document-status';

type DocPageProps = {
params: {
Expand All @@ -18,12 +18,12 @@ export default function DocPage({ params }: DocPageProps) {

return (
<section className="flex flex-col gap-2xl grow">
{document.status !== "stable" ? (
{document.status !== 'stable' ? (
<div>
<DocumentStatus status={document.status} />
</div>
) : null}
{document.status !== "coming-soon" ? (
{document.status !== 'coming-soon' ? (
<div>
<Mdx code={document.body.code} />
</div>
Expand Down
28 changes: 14 additions & 14 deletions apps/docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import type { Metadata } from "next";
import { Lato } from "next/font/google";
import { ThemeProvider } from "next-themes";
import "./globals.css";
import "@govie-ds/theme-govie/theme.css";
import { Container } from "@/components/chrome/container";
import { Footer } from "@/components/chrome/footer";
import { TopBar } from "@/components/chrome/top-bar";
import type { Metadata } from 'next';
import { Lato } from 'next/font/google';
import { ThemeProvider } from 'next-themes';
import './globals.css';
import '@govie-ds/theme-govie/theme.css';
import { Container } from '@/components/chrome/container';
import { Footer } from '@/components/chrome/footer';
import { TopBar } from '@/components/chrome/top-bar';

const lato = Lato({
weight: ["100", "300", "400", "700", "900"],
style: ["normal", "italic"],
subsets: ["latin"],
display: "swap",
weight: ['100', '300', '400', '700', '900'],
style: ['normal', 'italic'],
subsets: ['latin'],
display: 'swap',
});

export const metadata: Metadata = {
title: "Design System",
description: "Design System",
title: 'Design System',
description: 'Design System',
};

export default function RootLayout({
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Heading } from "@/components/typography/heading";
import { Heading } from '@/components/typography/heading';

export default function NotFoundPage() {
return <Heading>Not Found</Heading>;
Expand Down
48 changes: 24 additions & 24 deletions apps/docs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Fragment } from "react";
import Image from "next/image";
import { Heading } from "@/components/typography/heading";
import { Text } from "@/components/typography/text";
import { Button } from "@/components/form/button";
import heroImage from "../../public/hero.png";
import { config } from "@/lib/config";
import { RightArrowIcon } from "@/components/icons/right-arrow-icon";
import { Fragment } from 'react';
import Image from 'next/image';
import { Heading } from '@/components/typography/heading';
import { Text } from '@/components/typography/text';
import { Button } from '@/components/form/button';
import heroImage from '../../public/hero.png';
import { config } from '@/lib/config';
import { RightArrowIcon } from '@/components/icons/right-arrow-icon';

function Prose({
as: As = "div",
as: As = 'div',
children,
className,
}: {
Expand All @@ -23,34 +23,34 @@ function Prose({

const benefits = [
{
title: "Efficiency",
title: 'Efficiency',
description:
"Streamline your design processes with a comprehensive suite of components, patterns, and guidelines.",
'Streamline your design processes with a comprehensive suite of components, patterns, and guidelines.',
},
{
title: "Consistency",
title: 'Consistency',
description:
"Ensure a cohesive user experience across your digital services with a unified design language.",
'Ensure a cohesive user experience across your digital services with a unified design language.',
},
{
title: "Accessibility",
title: 'Accessibility',
description:
"Meet WCAG 2.1 AA standards with accessible components and inclusive design principles.",
'Meet WCAG 2.1 AA standards with accessible components and inclusive design principles.',
},
{
title: "Performance",
title: 'Performance',
description:
"Deliver fast and responsive digital services with lightweight components and optimised assets.",
'Deliver fast and responsive digital services with lightweight components and optimised assets.',
},
{
title: "Responsive",
title: 'Responsive',
description:
"Create digital services that work across all devices and screen sizes with responsive components and layouts.",
'Create digital services that work across all devices and screen sizes with responsive components and layouts.',
},
{
title: "Compliance",
title: 'Compliance',
description:
"Ensure compliance with government standards and regulations with the Design System building block.",
'Ensure compliance with government standards and regulations with the Design System building block.',
},
];

Expand Down Expand Up @@ -97,13 +97,13 @@ function Feedback() {
Alpha
</div>
<p className="text-gray-700 text-xs sm:text-md">
This is a new service - your{" "}
This is a new service - your{' '}
<a
className="underline text-blue-700 hover:decoration-md"
href={config.feedbackFormUrl}
>
feedback
</a>{" "}
</a>{' '}
will help us to improve it.
</p>
</div>
Expand Down Expand Up @@ -137,7 +137,7 @@ export default function HomePage() {
<Image
src={heroImage}
alt="Design system"
style={{ minWidth: "360px", width: "100%", height: "auto" }}
style={{ minWidth: '360px', width: '100%', height: 'auto' }}
priority
/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/src/components/chrome/container.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { cn } from "@/lib/cn";
import { cn } from '@/lib/cn';

export function Container({
as: As = "div",
as: As = 'div',
children,
className,
}: {
as?: React.ElementType;
children: React.ReactNode;
className?: string;
}) {
return <As className={cn("container mx-auto", className)}>{children}</As>;
return <As className={cn('container mx-auto', className)}>{children}</As>;
}
12 changes: 6 additions & 6 deletions apps/docs/src/components/chrome/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image from "next/image";
import { Container } from "./container";
import footerImage from "../../../public/logotype.png";
import { OglLogo } from "../logos/ogl-logo";
import Image from 'next/image';
import { Container } from './container';
import footerImage from '../../../public/logotype.png';
import { OglLogo } from '../logos/ogl-logo';

export function Footer() {
return (
Expand All @@ -11,7 +11,7 @@ export function Footer() {
<div className="flex gap-x-2xl items-center">
<OglLogo />
<span>
All content is available under the{" "}
All content is available under the{' '}
<a
className="underline hover:decoration-4" // TODO: add to theme
href="#"
Expand All @@ -26,7 +26,7 @@ export function Footer() {
src={footerImage}
alt="OGCIO"
width={190}
style={{ height: "auto" }}
style={{ height: 'auto' }}
/>
</div>
</Container>
Expand Down
28 changes: 17 additions & 11 deletions apps/docs/src/components/chrome/header.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import { Container } from "./container";
import { Logo } from "../logos/logo";
import { MenuIcon } from "../icons/menu-icon";
import { config } from "@/lib/config";
import { Container } from './container';
import { Logo } from '../logos/logo';
import { MenuIcon } from '../icons/menu-icon';
import { config } from '@/lib/config';

export type HeaderProps = {
showMobileMenu: boolean;
onMobileMenuSelect?: () => void;
};

export function Header({ onMobileMenuSelect = () => {} }: HeaderProps) {
export function Header({
showMobileMenu,
onMobileMenuSelect = () => {},
}: HeaderProps) {
return (
<div className="bg-emerald-800 border-b-lg border-gold-500">
<Container>
<div className="flex items-center py-xl gap-lg text-white">
{/* <button
className="block sm:hidden"
onClick={() => onMobileMenuSelect()}
>
<MenuIcon />
</button> */}
{showMobileMenu ? (
<button
className="block sm:hidden"
onClick={() => onMobileMenuSelect()}
>
<MenuIcon />
</button>
) : null}
<a
className="border-b-lg border-emerald-800 hover:border-white"
href={config.buildingBlocksHomeUrl}
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/src/components/chrome/theme-changer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from "react";
import { useTheme } from "next-themes";
'use client';
import { useState, useEffect } from 'react';
import { useTheme } from 'next-themes';

export function ThemeSwitch() {
const [mounted, setMounted] = useState(false);
Expand Down
18 changes: 12 additions & 6 deletions apps/docs/src/components/chrome/top-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
"use client";
import { useState } from "react";
import { Header } from "./header";
import { MainMenuConnected } from "../navigation/main-menu-connected";
import { MobileMenuConnected } from "../navigation/mobile-menu-connected";
'use client';
import { useState } from 'react';
import { Header } from './header';
import { MainMenuConnected } from '../navigation/main-menu-connected';
import { MobileMenuConnected } from '../navigation/mobile-menu-connected';
import { usePathname } from 'next/navigation';

export function TopBar() {
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();

// TODO: review showing main menu on the home page
return (
<div>
<Header onMobileMenuSelect={() => setIsOpen((isOpen) => !isOpen)} />
<Header
showMobileMenu={pathname === '/' ? false : true}
onMobileMenuSelect={() => setIsOpen((isOpen) => !isOpen)}
/>
<MainMenuConnected />
<MobileMenuConnected
isOpen={isOpen}
Expand Down
12 changes: 6 additions & 6 deletions apps/docs/src/components/document/color/color-primitives.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { meta as govieMeta } from "@govie-ds/theme-govie";
import { objectKeys } from "ts-extras";
import { SwatchSets } from "./swatch-sets";
import camelcase from "camelcase";
import { meta as govieMeta } from '@govie-ds/theme-govie';
import { objectKeys } from 'ts-extras';
import { SwatchSets } from './swatch-sets';
import camelcase from 'camelcase';

type Token = {
$type: string;
$value: string;
};

function dtcgToSet(
set: Record<string, Token>
set: Record<string, Token>,
): { name: number; value: string }[] {
return Object.entries(set).map(([name, value]) => ({
name: Number(name),
Expand All @@ -22,7 +22,7 @@ export function ColorPrimitives({}) {
(key) => ({
name: camelcase(key, { pascalCase: true }),
set: dtcgToSet(govieMeta.light.resolved.primitive.color[key]),
})
}),
);

return <SwatchSets sets={sets} />;
Expand Down
10 changes: 5 additions & 5 deletions apps/docs/src/components/document/color/color.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import convert from "color-convert";
import { TokenName } from "./token-name";
import convert from 'color-convert';
import { TokenName } from './token-name';

export function Color({
name,
Expand Down Expand Up @@ -33,15 +33,15 @@ export function Color({
<div className="text-sm text-gray-600">{value}</div>
<div>RGB</div>
<div className="text-sm text-gray-600">
{convert.hex.rgb(value).join(", ")}
{convert.hex.rgb(value).join(', ')}
</div>
<div>HSL</div>
<div className="text-sm text-gray-600">
{convert.hex.hsl(value).join(", ")}
{convert.hex.hsl(value).join(', ')}
</div>
<div>CMYK</div>
<div className="text-sm text-gray-600">
{convert.hex.cmyk(value).join(", ")}
{convert.hex.cmyk(value).join(', ')}
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/src/components/document/color/swatch-set.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fragment } from "react/jsx-runtime";
import { Swatch, SwatchProps } from "./swatch";
import { Fragment } from 'react/jsx-runtime';
import { Swatch, SwatchProps } from './swatch';

export type SwatchSetProps = {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/src/components/document/color/swatch-sets.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fragment } from "react/jsx-runtime";
import { SwatchSet, SwatchSetProps } from "./swatch-set";
import { Fragment } from 'react/jsx-runtime';
import { SwatchSet, SwatchSetProps } from './swatch-set';

export type SwatchSetsProps = {
sets: SwatchSetProps[];
Expand Down
Loading

0 comments on commit 3b143e2

Please sign in to comment.