feat: dark mode (#32)

This commit is contained in:
Ludvig Lundgren 2021-09-26 16:52:37 +02:00 committed by GitHub
parent 974ca95d80
commit 66048c5533
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 1736 additions and 1992 deletions

View file

@ -1,7 +1,7 @@
import { Field } from "react-final-form";
import React from "react";
import Error from "./Error";
import {classNames} from "../../styles/utils";
import { classNames } from "../../styles/utils";
type COL_WIDTHS = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
@ -14,30 +14,30 @@ interface Props {
autoComplete?: string;
}
const PasswordField: React.FC<Props> = ({ name, label, placeholder, columns , className, autoComplete}) => (
const PasswordField: React.FC<Props> = ({ name, label, placeholder, columns, className, autoComplete }) => (
<div
className={classNames(
columns ? `col-span-${columns}` : "col-span-12"
)}
>
{label && (
<label htmlFor={name} className="block text-xs font-bold text-gray-700 uppercase tracking-wide">
<label htmlFor={name} className="block text-xs font-bold text-gray-700 dark:text-white uppercase tracking-wide">
{label}
</label>
)}
<Field
name={name}
render={({input, meta}) => (
render={({ input }) => (
<input
{...input}
id={name}
type="password"
autoComplete={autoComplete}
className="mt-2 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-light-blue-500 focus:border-light-blue-500 sm:text-sm"
className="mt-2 block w-full border border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-white rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
placeholder={placeholder}
/>
)}
/>
/>
<div>
<Error name={name} classNames="text-red mt-2" />
</div>

View file

@ -1,7 +1,7 @@
import React from "react";
import {Switch} from "@headlessui/react";
import {Field} from "react-final-form";
import {classNames} from "../../styles/utils";
import { Switch } from "@headlessui/react";
import { Field } from "react-final-form";
import { classNames } from "../../styles/utils";
interface Props {
name: string;
@ -11,32 +11,32 @@ interface Props {
className?: string;
}
const SwitchGroup: React.FC<Props> = ({name, label, description, defaultValue}) => (
<ul className="mt-2 divide-y divide-gray-200">
const SwitchGroup: React.FC<Props> = ({ name, label, description, defaultValue }) => (
<ul className="mt-2 divide-y divide-gray-200 dark:divide-gray-700">
<Switch.Group as="li" className="py-4 flex items-center justify-between">
<div className="flex flex-col">
<Switch.Label as="p" className="text-sm font-medium text-gray-900"
passive>
<Switch.Label as="p" className="text-sm font-medium text-gray-900 dark:text-white"
passive>
{label}
</Switch.Label>
{description && (
<Switch.Description className="text-sm text-gray-500">
{description}
</Switch.Description>
<Switch.Description className="text-sm text-gray-500 dark:text-gray-700">
{description}
</Switch.Description>
)}
</div>
<Field
name={name}
defaultValue={defaultValue as any}
render={({input: {onChange, checked, value}}) => (
render={({ input: { onChange, checked, value } }) => (
<Switch
value={value}
checked={value}
onChange={onChange}
className={classNames(
value ? 'bg-teal-500' : 'bg-gray-200',
'ml-4 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-light-blue-500'
value ? 'bg-teal-500 dark:bg-blue-500' : 'bg-gray-200 dark:bg-gray-500',
'ml-4 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500'
)}
>
<span className="sr-only">Use setting</span>

View file

@ -1,7 +1,7 @@
import { Field } from "react-final-form";
import React from "react";
import { Field } from "react-final-form";
import Error from "./Error";
import {classNames} from "../../styles/utils";
import { classNames } from "../../styles/utils";
type COL_WIDTHS = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
@ -14,31 +14,31 @@ interface Props {
autoComplete?: string;
}
const TextField: React.FC<Props> = ({ name, label, placeholder, columns , className, autoComplete}) => (
const TextField: React.FC<Props> = ({ name, label, placeholder, columns, className, autoComplete }) => (
<div
className={classNames(
columns ? `col-span-${columns}` : "col-span-12"
)}
>
{label && (
<label htmlFor={name} className="block text-xs font-bold text-gray-700 uppercase tracking-wide">
<label htmlFor={name} className="block text-xs font-bold text-gray-700 dark:text-white uppercase tracking-wide">
{label}
</label>
)}
<Field
name={name}
render={({input, meta}) => (
render={({ input }) => (
<input
{...input}
id={name}
type="text"
value={input.value}
autoComplete={autoComplete}
className="mt-2 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-light-blue-500 focus:border-light-blue-500 sm:text-sm"
className="mt-2 block w-full border border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-white rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm"
placeholder={placeholder}
/>
)}
/>
/>
<div>
<Error name={name} classNames="text-red mt-2" />
</div>

View file

@ -1,5 +1,5 @@
import { Field } from "react-final-form";
import React from "react";
import { Field } from "react-final-form";
import Error from "./Error";
import { classNames } from "../../styles/utils";
@ -14,12 +14,12 @@ interface Props {
hidden?: boolean;
}
const TextFieldWide: React.FC<Props> = ({ name, label, help, placeholder, defaultValue, required, hidden, className}) => (
const TextFieldWide: React.FC<Props> = ({ name, label, help, placeholder, defaultValue, required, hidden, className }) => (
<div hidden={hidden}
className="space-y-1 px-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
<div>
<label htmlFor={name} className="block text-sm font-medium text-gray-900 sm:mt-px sm:pt-2">
<label htmlFor={name} className="block text-sm font-medium text-gray-900 dark:text-white sm:mt-px sm:pt-2">
{label} {required && <span className="text-gray-500">*</span>}
</label>
</div>
@ -32,7 +32,7 @@ const TextFieldWide: React.FC<Props> = ({ name, label, help, placeholder, defaul
{...input}
id={name}
type="text"
className={classNames(meta.touched && meta.error ? "focus:ring-red-500 focus:border-red-500 border-red-500" : "focus:ring-indigo-500 focus:border-indigo-500 border-gray-300", "block w-full shadow-sm sm:text-sm rounded-md")}
className={classNames(meta.touched && meta.error ? "focus:ring-red-500 focus:border-red-500 border-red-500" : "focus:ring-indigo-500 dark:focus:ring-blue-500 focus:border-indigo-500 dark:focus:border-blue-500 border-gray-300 dark:border-gray-700", "block w-full shadow-sm dark:bg-gray-800 sm:text-sm dark:text-white rounded-md")}
placeholder={placeholder}
hidden={hidden}
/>

View file

@ -1,5 +1,5 @@
import { Field } from "react-final-form";
import React from "react";
import { Field } from "react-final-form";
import Error from "../Error";
import { classNames } from "../../../styles/utils";
@ -28,7 +28,7 @@ const NumberFieldWide: React.FC<Props> = ({
<div>
<label
htmlFor={name}
className="block text-sm font-medium text-gray-900 sm:mt-px sm:pt-2"
className="block text-sm font-medium text-gray-900 dark:text-white sm:mt-px sm:pt-2"
>
{label} {required && <span className="text-gray-500">*</span>}
</label>
@ -46,15 +46,15 @@ const NumberFieldWide: React.FC<Props> = ({
className={classNames(
meta.touched && meta.error
? "focus:ring-red-500 focus:border-red-500 border-red-500"
: "focus:ring-indigo-500 focus:border-indigo-500 border-gray-300",
"block w-full shadow-sm sm:text-sm rounded-md"
: "focus:ring-indigo-500 dark:focus:ring-blue-500 focus:border-indigo-500 dark:focus:border-blue-500 border-gray-300 dark:border-gray-700",
"block w-full shadow-sm dark:bg-gray-800 sm:text-sm dark:text-white rounded-md"
)}
placeholder={placeholder}
/>
)}
/>
{help && (
<p className="mt-2 text-sm text-gray-500" id={`${name}-description`}>{help}</p>
<p className="mt-2 text-sm text-gray-500 dark:text-gray-200" id={`${name}-description`}>{help}</p>
)}
<Error name={name} classNames="block text-red-500 mt-2" />
</div>

View file

@ -21,7 +21,7 @@ function PasswordField({ name, label, placeholder, defaultValue, help, required
className="space-y-1 px-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
<div>
<label htmlFor={name} className="block text-sm font-medium text-gray-900 sm:mt-px sm:pt-2">
<label htmlFor={name} className="block text-sm font-medium text-gray-900 dark:text-white sm:mt-px sm:pt-2">
{label} {required && <span className="text-gray-500">*</span>}
</label>
</div>
@ -35,7 +35,7 @@ function PasswordField({ name, label, placeholder, defaultValue, help, required
{...input}
id={name}
type={isVisible ? "text" : "password"}
className={classNames(meta.touched && meta.error ? "focus:ring-red-500 focus:border-red-500 border-red-500" : "focus:ring-indigo-500 focus:border-indigo-500 border-gray-300", "block w-full shadow-sm sm:text-sm rounded-md")}
className={classNames(meta.touched && meta.error ? "focus:ring-red-500 focus:border-red-500 border-red-500" : "focus:ring-indigo-500 dark:focus:ring-blue-500 focus:border-indigo-500 dark:focus:border-blue-500 border-gray-300 dark:border-gray-700", "block w-full dark:bg-gray-800 shadow-sm dark:text-gray-100 sm:text-sm rounded-md")}
placeholder={placeholder}
/>
<div className="absolute inset-y-0 right-0 px-3 flex items-center" onClick={toggleVisibility}>

View file

@ -17,7 +17,7 @@ function RadioFieldsetWide({ name, legend, options }: props) {
<fieldset>
<div className="space-y-2 px-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:px-6 sm:py-5">
<div>
<legend className="text-sm font-medium text-gray-900">
<legend className="text-sm font-medium text-gray-900 dark:text-white">
{legend}
</legend>
</div>
@ -31,7 +31,7 @@ function RadioFieldsetWide({ name, legend, options }: props) {
<RadioGroup.Label className="sr-only">
Privacy setting
</RadioGroup.Label>
<div className="bg-white rounded-md -space-y-px">
<div className="bg-white dark:bg-gray-800 rounded-md -space-y-px">
{options.map((setting, settingIdx) => (
<RadioGroup.Option
key={setting.value}
@ -45,8 +45,8 @@ function RadioFieldsetWide({ name, legend, options }: props) {
? "rounded-bl-md rounded-br-md"
: "",
checked
? "bg-indigo-50 border-indigo-200 z-10"
: "border-gray-200",
? "bg-indigo-50 dark:bg-gray-700 border-indigo-200 dark:border-blue-600 z-10"
: "border-gray-200 dark:border-gray-700",
"relative border p-4 flex cursor-pointer focus:outline-none"
)
}
@ -56,10 +56,10 @@ function RadioFieldsetWide({ name, legend, options }: props) {
<span
className={classNames(
checked
? "bg-indigo-600 border-transparent"
: "bg-white border-gray-300",
? "bg-indigo-600 dark:bg-blue-600 border-transparent"
: "bg-white border-gray-300 dark:border-gray-300",
active
? "ring-2 ring-offset-2 ring-indigo-500"
? "ring-2 ring-offset-2 ring-indigo-500 dark:ring-blue-500"
: "",
"h-4 w-4 mt-0.5 cursor-pointer rounded-full border flex items-center justify-center"
)}
@ -71,7 +71,7 @@ function RadioFieldsetWide({ name, legend, options }: props) {
<RadioGroup.Label
as="span"
className={classNames(
checked ? "text-indigo-900" : "text-gray-900",
checked ? "text-indigo-900 dark:text-blue-500" : "text-gray-900 dark:text-gray-300",
"block text-sm font-medium"
)}
>
@ -80,7 +80,7 @@ function RadioFieldsetWide({ name, legend, options }: props) {
<RadioGroup.Description
as="span"
className={classNames(
checked ? "text-indigo-700" : "text-gray-500",
checked ? "text-indigo-700 dark:text-blue-500" : "text-gray-500",
"block text-sm"
)}
>