diff --git a/.node-version b/.node-version new file mode 100644 index 000000000..f203ab89b --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +20.13.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..08d091e3a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: +- hooks: + - id: commitizen + - id: commitizen-branch + stages: + - push + repo: https://github.com/commitizen-tools/commitizen + rev: v3.27.0 diff --git a/app/frontend/Components/Button/CheckinButton.tsx b/app/frontend/Components/Button/CheckinButton.tsx index d2091d0f1..d760f5898 100644 --- a/app/frontend/Components/Button/CheckinButton.tsx +++ b/app/frontend/Components/Button/CheckinButton.tsx @@ -3,6 +3,7 @@ import { Link } from '@/Components' import { type LinkProps } from '../Link' import { CheckinIcon } from '@/Components/Icons' import { Tooltip, useMantineTheme } from '@mantine/core' +import { useContrastingTextColor } from '@/lib/hooks' interface CheckinButtonProps extends Omit { href: string @@ -38,7 +39,7 @@ const CheckinButton = ({ href, label, disabled, tooltipMessage, ...props }: Chec aria-label={ usedLabel } { ...finalProps } > - + ) diff --git a/app/frontend/Components/Button/CheckoutButton.tsx b/app/frontend/Components/Button/CheckoutButton.tsx index 1100e0586..b059f8771 100644 --- a/app/frontend/Components/Button/CheckoutButton.tsx +++ b/app/frontend/Components/Button/CheckoutButton.tsx @@ -3,6 +3,7 @@ import { Link } from '@/Components' import { type LinkProps } from '../Link' import { CheckoutIcon } from '@/Components/Icons' import { Tooltip, useMantineTheme } from '@mantine/core' +import { useContrastingTextColor } from '@/lib/hooks' interface CheckoutButtonProps extends Omit { href: string @@ -31,7 +32,7 @@ const CheckoutButton = ({ href, label, disabled, tooltipMessage, ...props }: Che aria-label={ usedLabel } { ...props } > - + ) diff --git a/app/frontend/Components/Button/DeleteButton.tsx b/app/frontend/Components/Button/DeleteButton.tsx index b6501ff92..789bd82f9 100644 --- a/app/frontend/Components/Button/DeleteButton.tsx +++ b/app/frontend/Components/Button/DeleteButton.tsx @@ -3,6 +3,7 @@ import { Link, Tooltip } from '@/Components' import { type LinkProps } from '../Link' import { TrashIcon } from '@/Components/Icons' import { useMantineTheme } from '@mantine/core' +import { useContrastingTextColor } from '@/lib/hooks' interface DeleteButtonProps extends Omit { label?: string @@ -23,7 +24,7 @@ const DeleteButton = ({ href, label, tooltipMessage }: DeleteButtonProps) => { color={ deleteButtonColor } > - + ) diff --git a/app/frontend/Components/Button/EditButton.tsx b/app/frontend/Components/Button/EditButton.tsx index 40ec9f990..4f81908c4 100644 --- a/app/frontend/Components/Button/EditButton.tsx +++ b/app/frontend/Components/Button/EditButton.tsx @@ -3,6 +3,7 @@ import { Link, Tooltip } from '@/Components' import { EditIcon } from '@/Components/Icons' import { LinkProps } from '../Link' import { useMantineTheme } from '@mantine/core' +import { useContrastingTextColor } from '@/lib/hooks' interface EditButtonProps extends Omit { label?: string @@ -22,7 +23,9 @@ const EditButton = ({ href, label }: EditButtonProps) => { aria-label={ usedLabel } color={ primaryColor } > - + + + ) } diff --git a/app/frontend/Components/Form/Form.css.ts b/app/frontend/Components/Form/Form.css.ts index 676fbbf9d..d9bae7347 100644 --- a/app/frontend/Components/Form/Form.css.ts +++ b/app/frontend/Components/Form/Form.css.ts @@ -127,6 +127,12 @@ export const fieldset = css` export const dynamicInputItem = css` .mantine-Paper-root { - background-color: ${vars.colors.gray[8] } + ${vars.lightSelector} { + background-color: ${vars.colors.gray[0] } + } + + ${vars.darkSelector} { + background-color: ${vars.colors.gray[8] } + } } ` diff --git a/app/frontend/Components/Table/SearchInput/ColumnPicker.tsx b/app/frontend/Components/Table/SearchInput/ColumnPicker.tsx index 061fa3dd4..aac5a2a1d 100644 --- a/app/frontend/Components/Table/SearchInput/ColumnPicker.tsx +++ b/app/frontend/Components/Table/SearchInput/ColumnPicker.tsx @@ -9,6 +9,9 @@ import { useTableContext } from '../TableContext' import { Button } from '@mantine/core' import { usePageProps } from '@/lib/hooks' +import cx from 'clsx' +import * as classes from '../Table.css' + const ColumnPicker = () => { const { auth: { user } } = usePageProps() const { tableState: { hideable, columns, model } } = useTableContext() @@ -34,7 +37,9 @@ const ColumnPicker = () => { return ( - + diff --git a/app/frontend/Components/Table/Table.css.ts b/app/frontend/Components/Table/Table.css.ts index b9d1f7219..4af17a5b0 100644 --- a/app/frontend/Components/Table/Table.css.ts +++ b/app/frontend/Components/Table/Table.css.ts @@ -137,9 +137,16 @@ export const searchInput = css` input { border-top-right-radius: 0; border-bottom-right-radius: 0; + border-top-left-radius: ${vars.radius.sm}; + border-bottom-left-radius: ${vars.radius.sm}; } ` +export const columnPickerButton = css` + border-top-left-radius: 0; + border-bottom-left-radius: 0; +` + export const pagination = css` display: inline-block; max-width: 60px; diff --git a/app/frontend/Features/Contactable/Form/index.tsx b/app/frontend/Features/Contactable/Form/index.tsx index 0c9dc07a8..e6a3442c7 100644 --- a/app/frontend/Features/Contactable/Form/index.tsx +++ b/app/frontend/Features/Contactable/Form/index.tsx @@ -6,11 +6,7 @@ import Phone from './Phone' import Email from './Email' import Website from './Website' -interface ContactableFormProps { - contact: Schema.ContactsFormData -} - -const ContactableForm = ({ contact }: ContactableFormProps) => { +const ContactableForm = () => { return ( diff --git a/app/frontend/Pages/Consumables/ReplenishButton.tsx b/app/frontend/Pages/Consumables/ReplenishButton.tsx index 9f7d23b4e..e18960d62 100644 --- a/app/frontend/Pages/Consumables/ReplenishButton.tsx +++ b/app/frontend/Pages/Consumables/ReplenishButton.tsx @@ -8,6 +8,7 @@ import { Routes } from '@/lib' import axios from 'axios' import { router } from '@inertiajs/react' import { type UseFormProps } from 'use-inertia-form' +import { useContrastingTextColor } from '@/lib/hooks' const defaultData = { consumable: { qty: 1 } } @@ -49,6 +50,8 @@ const ReplenishButton = ({ consumable, disabled, tooltipMessage, ...props }: Rep return false } + const textColor = useContrastingTextColor(replenishButtonColor) + return ( <> diff --git a/app/frontend/Pages/People/Edit/Form.tsx b/app/frontend/Pages/People/Edit/Form.tsx index 97aba149e..c66590f57 100644 --- a/app/frontend/Pages/People/Edit/Form.tsx +++ b/app/frontend/Pages/People/Edit/Form.tsx @@ -15,6 +15,7 @@ import { useBooleanToggle } from '@/lib/hooks' import { FormPeopleDropdown, FormDepartmentsDropdown } from '@/Features/Dropdowns' import { coerceArray } from '@/lib' import { type HTTPVerb, type UseFormProps } from 'use-inertia-form' +import { ContactForm } from '@/Features' type PersonFormData = { person: Schema.PeopleEdit @@ -213,6 +214,8 @@ const PersonForm = ({ } + + { person.id ? 'Update' : 'Create' } Person diff --git a/app/frontend/lib/hooks/index.ts b/app/frontend/lib/hooks/index.ts index 61269048c..2ce998e87 100644 --- a/app/frontend/lib/hooks/index.ts +++ b/app/frontend/lib/hooks/index.ts @@ -4,5 +4,6 @@ export { default as useCheckboxState } from './useCheckboxState' export { default as useLocation } from './useLocation' export { default as usePageProps } from './usePageProps' export { default as useInit } from './useInit' +export { default as useContrastingTextColor } from './useContrastingTextColor' export { default as useCurrency, type UseCurrencyOptions } from './useCurrency' export { useListState, useToggle, useViewportSize } from '@mantine/hooks' diff --git a/app/frontend/lib/hooks/useContrastingTextColor.ts b/app/frontend/lib/hooks/useContrastingTextColor.ts new file mode 100644 index 000000000..cae4872d1 --- /dev/null +++ b/app/frontend/lib/hooks/useContrastingTextColor.ts @@ -0,0 +1,18 @@ +import { isLightColor, type MantinePrimaryShade, useMantineColorScheme, useMantineTheme } from '@mantine/core' + +const useContrastingTextColor = (color: string) => { + const { colors, primaryShade } = useMantineTheme() + const { colorScheme } = useMantineColorScheme() + + if(color === undefined) return 'black' + + let validatedColor = color + if(Object.keys(colors).includes(color)) { + const shade = (primaryShade as MantinePrimaryShade)[(colorScheme as 'light'|'dark')] + validatedColor = colors[color][shade] + } + + return isLightColor(validatedColor, 0.379) ? 'black' : 'white' +} + +export default useContrastingTextColor