Finished converting current CSS to Tailwind

This commit is contained in:
DrMint 2022-01-02 16:14:39 +01:00
parent 8e077d2c6f
commit 9daf218c51
21 changed files with 172 additions and 337 deletions

View File

@ -1,20 +1,14 @@
import { GetChronologyItemsQuery } from "graphql/operations-types"; import { GetChronologyItemsQuery } from "graphql/operations-types";
import styles from "styles/Chronology/ChronologyItemComponent.module.css";
export type ChronologyItemComponentProps = { export type ChronologyItemComponentProps = {
item: GetChronologyItemsQuery['chronologyItems']['data'][number]; item: GetChronologyItemsQuery["chronologyItems"]["data"][number];
displayYear: boolean; displayYear: boolean;
}; };
export default function ChronologyItemComponent( export default function ChronologyItemComponent(
props: ChronologyItemComponentProps props: ChronologyItemComponentProps
): JSX.Element { ): JSX.Element {
function generateAnchor( function generateAnchor(year: number, month: number, day: number): string {
year: number,
month: number,
day: number,
event?: number
): string {
let result: string = ""; let result: string = "";
result += year; result += year;
if (month) result += "-" + month.toString().padStart(2, "0"); if (month) result += "-" + month.toString().padStart(2, "0");
@ -59,7 +53,7 @@ export default function ChronologyItemComponent(
return ( return (
<div <div
className={styles.chronologyItem} className="grid place-content-start grid-rows-[auto_1fr] grid-cols-[4em] py-4 px-8 rounded-2xl target:bg-mid"
id={generateAnchor( id={generateAnchor(
props.item.attributes.year, props.item.attributes.year,
props.item.attributes.month, props.item.attributes.month,
@ -67,7 +61,7 @@ export default function ChronologyItemComponent(
)} )}
> >
{props.displayYear ? ( {props.displayYear ? (
<p className={styles.year}> <p className="text-lg font-bold">
{generateYear( {generateYear(
props.item.attributes.displayed_date, props.item.attributes.displayed_date,
props.item.attributes.year props.item.attributes.year
@ -77,13 +71,13 @@ export default function ChronologyItemComponent(
"" ""
)} )}
<p className={styles.date}> <p className="col-start-1 text-dark text-sm">
{generateDate(props.item.attributes.month, props.item.attributes.day)} {generateDate(props.item.attributes.month, props.item.attributes.day)}
</p> </p>
<div className={styles.events}> <div className="col-start-2 row-start-1 row-span-2">
{props.item.attributes.events.map((event) => ( {props.item.attributes.events.map((event) => (
<div className={styles.event} key={event.id}> <div className="m-0" key={event.id}>
{event.translations.map((translation) => ( {event.translations.map((translation) => (
<> <>
{translation.title ? <h3>{translation.title}</h3> : ""} {translation.title ? <h3>{translation.title}</h3> : ""}
@ -91,7 +85,9 @@ export default function ChronologyItemComponent(
{translation.description ? ( {translation.description ? (
<p <p
className={ className={
event.translations.length > 1 ? styles.bulletItem : "" event.translations.length > 1
? "before:content-['-'] before:text-dark before:inline-block before:w-4 before:ml-[-1em] mt-2 whitespace-pre-line"
: "whitespace-pre-line"
} }
> >
{translation.description} {translation.description}
@ -107,7 +103,7 @@ export default function ChronologyItemComponent(
</> </>
))} ))}
<p className={styles.source}> <p className="text-dark text-xs">
{event.source.data {event.source.data
? "(" + event.source.data.attributes.name + ")" ? "(" + event.source.data.attributes.name + ")"
: "(WARNING: NO SOURCE!)"} : "(WARNING: NO SOURCE!)"}

View File

@ -1,4 +1,3 @@
import styles from "styles/Chronology/ChronologyYearComponent.module.css";
import ChronologyItemComponent from "components/Chronology/ChronologyItemComponent"; import ChronologyItemComponent from "components/Chronology/ChronologyItemComponent";
import { GetChronologyItemsQuery } from "graphql/operations-types"; import { GetChronologyItemsQuery } from "graphql/operations-types";
@ -12,7 +11,7 @@ export default function ChronologyYearComponent(
): JSX.Element { ): JSX.Element {
return ( return (
<div <div
className={styles.chronologyYear} className="target:bg-mid rounded-2xl target:py-4 target:my-4"
id={props.items.length > 1 ? props.year.toString() : undefined} id={props.items.length > 1 ? props.year.toString() : undefined}
> >
{props.items.map((item, index) => ( {props.items.map((item, index) => (

View File

@ -1,13 +1,22 @@
type ContentPanelProps = { type ContentPanelProps = {
children: React.ReactNode; children: React.ReactNode;
autoformat?: boolean;
}; };
export default function ContentPanel(props: ContentPanelProps): JSX.Element { export default function ContentPanel(props: ContentPanelProps): JSX.Element {
if (props.autoformat) {
return ( return (
<div className="w-full grid overflow-y-scroll max-h-screen py-20 px-10"> <div className="w-full grid overflow-y-scroll max-h-screen py-20 px-10">
<main className="prose lg:prose-lg place-self-center text-justify"> <main className="prose place-self-center text-justify">
{props.children} {props.children}
</main> </main>
</div> </div>
); );
} else {
return (
<div className="w-full grid overflow-y-scroll max-h-screen py-20 px-10">
<main className="place-self-center text-justify">{props.children}</main>
</div>
);
}
} }

View File

@ -1,15 +1,17 @@
import Link from "next/link"; import Link from "next/link";
import styles from "styles/Panels/MainPanel.module.css";
import panelStyles from "styles/Panels/Panels.module.css";
import NavOption from "components/Panels/NavOption"; import NavOption from "components/Panels/NavOption";
export default function MainPanel(): JSX.Element { export default function MainPanel(): JSX.Element {
return ( return (
<div className={`${panelStyles.panel} ${styles.panel}`}> <div className="grid webkit-scrollbar:w-0 [scrollbar-width:none] overflow-y-scroll border-r-[1px] border-black w-80 h-full max-h-screen justify-center content-start p-8 gap-y-2 justify-items-center text-center">
<Link href="/" passHref> <Link href="/" passHref>
<div className={styles.topLogo}> <div className="grid place-items-center cursor-pointer">
<img src="/icons/accords.svg" alt="" /> <img
<h2>Accord&apos;s Library</h2> className="w-1/2 self-start justify-center"
src="/icons/accords.svg"
alt=""
/>
<h2 className="mt-4">Accord&apos;s Library</h2>
</div> </div>
</Link> </Link>
@ -70,9 +72,21 @@ export default function MainPanel(): JSX.Element {
</p> </p>
<a href="https://creativecommons.org/licenses/by-sa/4.0/"> <a href="https://creativecommons.org/licenses/by-sa/4.0/">
<div className="mt-4 mb-8 grid h-4 grid-flow-col place-content-center gap-1"> <div className="mt-4 mb-8 grid h-4 grid-flow-col place-content-center gap-1">
<img className="h-6" src="/icons/creative-commons-brands.svg" alt="" /> <img
<img className="h-6" src="/icons/creative-commons-by-brands.svg" alt="" /> className="h-6"
<img className="h-6" src="/icons/creative-commons-sa-brands.svg" alt="" /> src="/icons/creative-commons-brands.svg"
alt=""
/>
<img
className="h-6"
src="/icons/creative-commons-by-brands.svg"
alt=""
/>
<img
className="h-6"
src="/icons/creative-commons-sa-brands.svg"
alt=""
/>
</div> </div>
</a> </a>
<p> <p>
@ -80,12 +94,12 @@ export default function MainPanel(): JSX.Element {
ENIX CO. LTD. All game assets and promotional materials belongs to © ENIX CO. LTD. All game assets and promotional materials belongs to ©
SQUARE ENIX CO. LTD. SQUARE ENIX CO. LTD.
</p> </p>
<div className={styles.menuFooterSocials}> <div className="mt-12 mb-4 grid h-4 grid-flow-col place-content-center gap-8">
<a href="https://github.com/Accords-Library"> <a href="https://github.com/Accords-Library">
<img src="/icons/github-brands.svg" alt="" /> <img className="h-8" src="/icons/github-brands.svg" alt="" />
</a> </a>
<a href="https://accords-library.com/discord"> <a href="https://accords-library.com/discord">
<img src="/icons/discord-brands.svg" alt="" /> <img className="h-8" src="/icons/discord-brands.svg" alt="" />
</a> </a>
</div> </div>
</div> </div>

View File

@ -1,28 +1,39 @@
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import styles from "styles/Panels/NavOption.module.css";
import Link from "next/link"; import Link from "next/link";
type NavOptionProps = { type NavOptionProps = {
url: string; url: string;
icon?: string; icon?: string;
title: string | null | undefined; title: string;
subtitle?: string; subtitle?: string;
border?: boolean; border?: boolean;
}; };
export default function NavOption(pageProps: NavOptionProps): JSX.Element { export default function NavOption(props: NavOptionProps): JSX.Element {
const router = useRouter(); const router = useRouter();
let classNames = [styles.menuOption]; const isActive = router.asPath.startsWith(props.url);
if (router.asPath.startsWith(pageProps.url)) classNames.push(styles.active); const divActive = "bg-mid"
if (pageProps.icon) classNames.push(styles.icon); const border = "border-2 border-mid";
if (pageProps.border === true) classNames.push(styles.border); const divCommon = `gap-x-4 w-full rounded-2xl cursor-pointer p-4 hover:bg-mid transition-colors ${props.border ? border: ""} ${isActive ? divActive : ""}`;
if (props.icon) {
return ( return (
<Link href={pageProps.url} passHref> <Link href={props.url} passHref>
<div className={classNames.join(" ")}> <div className={`grid grid-cols-[auto_1fr] text-left ${divCommon}`}>
{pageProps.icon && <img src={pageProps.icon} alt="" />} <img className="w-5" src={props.icon} alt="" />
<h3>{pageProps.title}</h3> <h3 className="text-2xl">{props.title}</h3>
{pageProps.subtitle && <p>{pageProps.subtitle}</p>} {props.subtitle && <p className="col-start-2">{props.subtitle}</p>}
</div> </div>
</Link> </Link>
); );
} else {
return (
<Link href={props.url} passHref>
<div className={`grid text-center ${divCommon}`}>
<h3 className="text-2xl">{props.title}</h3>
{props.subtitle && <p>{props.subtitle}</p>}
</div>
</Link>
);
}
} }

View File

@ -1,4 +1,3 @@
import styles from "styles/Panels/ReturnButton.module.css";
import Link from "next/link"; import Link from "next/link";
type ReturnButtonProps = { type ReturnButtonProps = {

View File

@ -1,13 +1,10 @@
import styles from "styles/Panels/SubPanel.module.css";
import panelStyles from "styles/Panels/Panels.module.css";
type SubPanelProps = { type SubPanelProps = {
children: React.ReactNode; children: React.ReactNode;
}; };
export default function SubPanel(props: SubPanelProps): JSX.Element { export default function SubPanel(props: SubPanelProps): JSX.Element {
return ( return (
<div className={[panelStyles.panel, styles.panel].join(" ")}> <div className="grid webkit-scrollbar:w-0 [scrollbar-width:none] border-r-[1px] overflow-y-scroll border-black w-80 h-full max-h-screen justify-center content-start p-8 gap-y-2 justify-items-center text-center">
{props.children} {props.children}
</div> </div>
); );

View File

@ -1,7 +1,41 @@
export type GetErasQueryVariables = { export type Exact<T> = T;
language_code: string; export type InputMaybe<T> = T;
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
JSON: any;
DateTime: any;
Time: any;
Upload: any;
LibraryContentRangeDynamicZoneInput: any;
LibraryItemMetadataDynamicZoneInput: any;
SourceSourceDynamicZoneInput: any;
}; };
/*
The following is generated using https://www.graphql-code-generator.com/
With the following codegen.yml:
generates:
operations-types.ts:
plugins:
- typescript-operations
And the schema.graphql and operation.graphql files from this folder.
But to make the type easier to work with, it went through the following transformation:
- Removed ?
- Removed | null
- Removed | undefined
*/
export type GetErasQueryVariables = Exact<{
language_code: InputMaybe<Scalars["String"]>;
}>;
export type GetErasQuery = { export type GetErasQuery = {
__typename: "Query"; __typename: "Query";
chronologyEras: { chronologyEras: {
@ -23,9 +57,9 @@ export type GetErasQuery = {
}; };
}; };
export type GetChronologyItemsQueryVariables = { export type GetChronologyItemsQueryVariables = Exact<{
language_code: string; language_code: InputMaybe<Scalars["String"]>;
}; }>;
export type GetChronologyItemsQuery = { export type GetChronologyItemsQuery = {
__typename: "Query"; __typename: "Query";
@ -66,9 +100,9 @@ export type GetChronologyItemsQuery = {
}; };
}; };
export type GetLibraryItemsPreviewQueryVariables = { export type GetLibraryItemsPreviewQueryVariables = Exact<{
language_code: string; language_code: InputMaybe<Scalars["String"]>;
}; }>;
export type GetLibraryItemsPreviewQuery = { export type GetLibraryItemsPreviewQuery = {
__typename: "Query"; __typename: "Query";
@ -133,9 +167,9 @@ export type GetLibraryItemsPreviewQuery = {
}; };
}; };
export type GetLibraryItemsSkeletonQueryVariables = { export type GetLibraryItemsSkeletonQueryVariables = Exact<{
[key: string]: never; [key: string]: never;
}; }>;
export type GetLibraryItemsSkeletonQuery = { export type GetLibraryItemsSkeletonQuery = {
__typename: "Query"; __typename: "Query";
@ -181,10 +215,10 @@ export type GetLibraryItemsSkeletonQuery = {
}; };
}; };
export type GetLibraryItemQueryVariables = { export type GetLibraryItemQueryVariables = Exact<{
slug: string; slug: InputMaybe<Scalars["String"]>;
language_code: string; language_code: InputMaybe<Scalars["String"]>;
}; }>;
export type GetLibraryItemQuery = { export type GetLibraryItemQuery = {
__typename: "Query"; __typename: "Query";
@ -213,14 +247,12 @@ export type GetLibraryItemQuery = {
}; };
}; };
}; };
release_date: { release_date: {
__typename: "ComponentBasicsDatepicker"; __typename: "ComponentBasicsDatepicker";
year: number; year: number;
month: number; month: number;
day: number; day: number;
}; };
price: { price: {
__typename: "ComponentBasicsPrice"; __typename: "ComponentBasicsPrice";
amount: number; amount: number;
@ -236,22 +268,16 @@ export type GetLibraryItemQuery = {
}; };
}; };
}; };
size: { size: {
__typename: "ComponentBasicsSize"; __typename: "ComponentBasicsSize";
width: number; width: number;
height: number; height: number;
thickness: number; thickness: number;
}; };
descriptions: Array<{
descriptions: Array<
| {
__typename: "ComponentTranslationsLibraryItems"; __typename: "ComponentTranslationsLibraryItems";
description: string; description: string;
} }>;
| undefined
>;
subitems: { subitems: {
__typename: "LibraryItemRelationResponseCollection"; __typename: "LibraryItemRelationResponseCollection";
data: Array<{ data: Array<{
@ -270,13 +296,9 @@ export type GetLibraryItemQuery = {
__typename: "UploadFile"; __typename: "UploadFile";
name: string; name: string;
alternativeText: string; alternativeText: string;
caption: string; caption: string;
width: number; width: number;
height: number; height: number;
url: string; url: string;
}; };
}; };

View File

@ -1,6 +1,6 @@
import type { AppProps } from "next/app"; import type { AppProps } from "next/app";
import MainPanel from "components/Panels/MainPanel"; import MainPanel from "components/Panels/MainPanel";
import "styles/index.css"; import "tailwind.css";
import "@fontsource/zen-maru-gothic/500.css"; import "@fontsource/zen-maru-gothic/500.css";
import "@fontsource/vollkorn/700.css"; import "@fontsource/vollkorn/700.css";
@ -17,23 +17,19 @@ export function applyCustomAppProps(
} }
export default function AccordsLibraryApp(appProps: AppProps) { export default function AccordsLibraryApp(appProps: AppProps) {
// Apply a different style depending on the given CustomAppProps return (
let mainClasses = "grid min-h-screen grid-flow-col"; <div
if ( className={
appProps.Component.customAppProps.useSubPanel && appProps.Component.customAppProps.useSubPanel &&
appProps.Component.customAppProps.useContentPanel appProps.Component.customAppProps.useContentPanel
) { ? "grid grid-cols-[20rem_20rem_1fr]"
mainClasses += " grid-cols-appUseSubContent"; : appProps.Component.customAppProps.useSubPanel
} else if (appProps.Component.customAppProps.useSubPanel) { ? "grid grid-cols-[20rem_20rem]"
mainClasses += " grid-cols-appUseSub"; : appProps.Component.customAppProps.useContentPanel
} else if (appProps.Component.customAppProps.useContentPanel) { ? "grid grid-cols-[20rem_1fr]"
mainClasses += " grid-cols-appUseContent"; : "grid grid-cols-[20rem]"
} else {
mainClasses += " grid-cols-appDefault";
} }
>
return (
<div className={mainClasses}>
<MainPanel /> <MainPanel />
<appProps.Component {...appProps.pageProps} /> <appProps.Component {...appProps.pageProps} />
</div> </div>

View File

@ -13,7 +13,7 @@ export default function Home(): JSX.Element {
<Head> <Head>
<title>Accord&rsquo;s Library - Home</title> <title>Accord&rsquo;s Library - Home</title>
</Head> </Head>
<ContentPanel> <ContentPanel autoformat={true}>
<h2>Discover Analyse Translate Archive</h2> <h2>Discover Analyse Translate Archive</h2>
<h2>What is this?</h2> <h2>What is this?</h2>
<p> <p>

View File

@ -1,66 +0,0 @@
.chronologyItem {
display: grid;
grid-template-areas:
"year events"
"date events"
;
grid-column-gap: 1em;
place-content: start;
grid-template-rows: auto 1fr;
grid-template-columns: 4em;
padding: 1em 2em;
}
.chronologyItem:target {
background-color: var(--color-main-base);
border-radius: 1em;
}
.chronologyItem > .year {
grid-area: year;
margin: 0;
font-weight: bold;
font-size: 1.3em;
margin-top: -0.25em;
}
.chronologyItem > .date {
grid-area: date;
margin: 0;
color: var(--color-main-dark);
font-size: 0.9em;
}
.chronologyItem > .events {
grid-area: events;
}
.event > h3 {
margin: 0;
}
.event > p {
margin: 0;
white-space: break-spaces;
}
.event > .bulletItem::before {
content: "";
color: var(--color-main-dark);
display: inline-block;
width: 1em;
margin-left: -1em
}
.event > .bulletItem {
margin-top: .5em;
}
.event ~ .event {
margin-top: 1em;
}
.source {
color: var(--color-main-dark);
font-size: 80%;
}

View File

@ -1,5 +0,0 @@
.chronologyYear:target {
background-color: var(--color-main-base);
border-radius: 1em;
padding: 1em 2em 1em 1.5em;
}

View File

@ -1,3 +0,0 @@
.libraryItem {
cursor: pointer;
}

View File

@ -1,15 +0,0 @@
.panel {
padding-top: 5rem;
scrollbar-width: thin;
border: none;
}
.panelInside {
max-width: 50rem;
text-align: justify;
text-justify: inter-word;
}
.panel::-webkit-scrollbar {
display: unset;
}

View File

@ -1,59 +0,0 @@
.topLogo {
display: grid;
place-items: center;
cursor: pointer;
}
.topLogo > h2 {
margin-top: 1rem;
}
.topLogo > img {
width: 50%;
height: auto;
place-self: start center;
}
.menuFooter {
text-align: center;
}
.menuFooterCC {
margin-top: 1rem;
margin-bottom: 2rem;
display: grid;
height: 1rem;
grid-auto-flow: column;
place-content: center;
grid-gap: .2rem;
}
.menuFooterCC img {
height: 1.5rem;
width: auto;
}
.menuFooterCC:hover img {
filter: var(--filter-color-main-dark);
}
.menuFooterSocials {
margin-top: 3rem;
margin-bottom: 1rem;
display: grid;
height: 1rem;
grid-auto-flow: column;
place-content: center;
grid-gap: 2rem;
}
.menuFooterSocials img {
height: 2rem;
width: auto;
transition: .1s filter;
}
.menuFooterSocials img:hover {
filter: var(--filter-color-main-dark);
}

View File

@ -1,46 +0,0 @@
.menuOption {
display: grid;
grid-template-areas: 'title' 'subtitle';
align-items: center;
border-radius: 1em;
grid-column-gap: 1em;
cursor: pointer;
padding: 0.6em 1.2em;
width: 100%;
transition: .1s background-color;
text-align: center;
}
.menuOption.icon {
grid-template-areas: 'icon title' '. subtitle';
grid-template-columns: auto 1fr;
text-align: start;
}
.menuOption.border {
border: 1px solid var(--color-main-base);
}
.menuOption:hover, .menuOption.active {
background-color: var(--color-main-base);
}
.menuOption > * {
margin: 0;
}
.menuOption > img {
width: 1.2em;
height: auto;
grid-area: icon;
}
.menuOption > h3 {
grid-area: title;
font-size: 150%;
}
.menuOption > p {
grid-area: subtitle;
}

View File

@ -1,25 +0,0 @@
.panel {
display: grid;
border-right: 1px solid black;
height: 100%;
max-height: 100vh;
justify-items: center;
padding: 2rem;
overflow-y: auto;
grid-row-gap: 0.5em;
place-content: start center;
scrollbar-width: none;
scroll-behavior: smooth;
}
.panel::-webkit-scrollbar {
display: none;
}
.panel > hr {
height: 0;
width: 100%;
border: none;
border-top: 0.3rem dotted black;
margin: 2rem;
}

View File

@ -1,3 +0,0 @@
.panel {
width: 20rem;
}

View File

@ -11,6 +11,16 @@
color: var(--color-main-black); color: var(--color-main-black);
} }
/* HORIZONTAL LINE */
hr {
height: 0;
width: 100%;
border: none;
border-top: 0.3rem dotted black;
margin: 2rem;
}
/* BUTTONS */ /* BUTTONS */
button { button {
@ -66,6 +76,7 @@
* { * {
scrollbar-color: theme("colors.dark") transparent; scrollbar-color: theme("colors.dark") transparent;
scrollbar-width: thin; scrollbar-width: thin;
scroll-behavior: smooth;
} }
*::selection { *::selection {
@ -91,4 +102,6 @@
border-radius: 100vmax; /* roundness of the scroll thumb */ border-radius: 100vmax; /* roundness of the scroll thumb */
border: 3px solid theme("colors.light"); /* creates padding around scroll thumb */ border: 3px solid theme("colors.light"); /* creates padding around scroll thumb */
} }
} }

View File

@ -1,22 +1,23 @@
const plugin = require('tailwindcss/plugin');
module.exports = { module.exports = {
content: ["./src/**/*.{tsx,ts}"], content: ["./src/**/*.{tsx,ts}"],
theme: { theme: {
colors: { colors: {
light: "#ffedd8", light: "#ffedd8",
base: "#e6ccb2", mid: "#e6ccb2",
dark: "#9c6644", dark: "#9c6644",
black: "#1B1811", black: "#1B1811",
}, },
extend: {
gridTemplateColumns: {
appDefault: "20rem",
appUseSub: "20rem 20rem",
appUseContent: "20rem 1fr",
appUseSubContent: "20rem 20rem 1fr",
},
},
}, },
plugins: [ plugins: [
require("@tailwindcss/typography"), require("@tailwindcss/typography"),
plugin(function({ addVariant, e }) {
addVariant('webkit-scrollbar', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`webkit-scrollbar${separator}${className}`)}::-webkit-scrollbar`
})
})
})
], ],
}; };