Skip to content

Commit

Permalink
wip: chore update hds
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Jan 13, 2025
1 parent 14d1f44 commit a853e8c
Show file tree
Hide file tree
Showing 126 changed files with 1,424 additions and 1,584 deletions.
3 changes: 2 additions & 1 deletion apps/admin-ui/jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const customJestConfig = {
modulePathIgnorePatterns: ["<rootDir>/.next/"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
moduleDirectories: ["node_modules", "<rootDir>/"],
testEnvironment: "jest-environment-jsdom",
// jsdom has broken stylesheet parsing
testEnvironment: "@happy-dom/jest-environment", // "jest-environment-jsdom",
};

const jestConfig = async () => {
Expand Down
7 changes: 4 additions & 3 deletions apps/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"eslint-config-custom": "workspace:*",
"form-data": "^4.0.0",
"graphql": "^16.9.0",
"hds-core": "^3.11.0",
"hds-react": "^3.11.0",
"hds-core": "^4.1.0",
"hds-react": "^4.1.0",
"i18next": "^23.15.1",
"lodash": "^4.17.21",
"next": "15.0.3",
Expand All @@ -64,6 +64,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@happy-dom/jest-environment": "^16.5.3",
"@svgr/webpack": "^8.1.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
Expand All @@ -78,9 +79,9 @@
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.29",
"@vercel/style-guide": "^6.0.0",
"happy-dom": "^16.5.3",
"jest": "^29.7.0",
"jest-axe": "^8.0.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.10",
"postcss-scss": "^4.0.9",
"postcss-styled-syntax": "^0.6.4",
Expand Down
15 changes: 8 additions & 7 deletions apps/admin-ui/src/common/ScrollToTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import { Button, IconAngleUp } from "hds-react";
import { useDebounce, useWindowSize } from "react-use";
import { breakpoints } from "common/src/common/style";

const Btn = styled(Button).attrs({
style: {
"--color-bus": "var(--color-black)",
} as React.CSSProperties,
})`
// "--color-bus": "var(--color-black)",
const Btn = styled(Button)`
width: 40px;
height: 40px;
background-color: var(--color-black);
Expand Down Expand Up @@ -54,9 +51,13 @@ function ScrollToTop(): JSX.Element | null {
300
);

const handleClick = () => {
window.scroll({ top: 0, left: 0, behavior: "smooth" });
}

Check failure on line 56 in apps/admin-ui/src/common/ScrollToTop.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Insert `;`

return isEnabled && isVisible ? (
<Btn onClick={() => window.scroll({ top: 0, left: 0, behavior: "smooth" })}>
<IconAngleUp />
<Btn onClick={handleClick} iconStart={<IconAngleUp />}>
""

Check failure on line 60 in apps/admin-ui/src/common/ScrollToTop.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

`"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`

Check failure on line 60 in apps/admin-ui/src/common/ScrollToTop.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

`"` can be escaped with `&quot;`, `&ldquo;`, `&#34;`, `&rdquo;`
</Btn>
) : null;
}
Expand Down
27 changes: 16 additions & 11 deletions apps/admin-ui/src/component/DenyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useTranslation } from "react-i18next";
import styled from "styled-components";
import {
Button,
ButtonVariant,
Dialog,
RadioButton,
Select,
SelectionGroup,
TextArea,
} from "hds-react";
Expand All @@ -19,14 +21,13 @@ import {
OrderStatus,
} from "@gql/gql-types";
import { useModal } from "@/context/ModalContext";
import { Select } from "@/component/Select";
import { CenterSpinner, Flex } from "common/styles/util";
import { CustomDialogHeader } from "@/component/CustomDialogHeader";
import { useDenyReasonOptions } from "@/hooks";
import { successToast, errorToast } from "common/src/common/toast";
import { gql } from "@apollo/client";
import { getValidationErrors } from "common/src/apolloUtils";
import { toNumber } from "common/src/helpers";
import { convertOptionToHDS, toNumber } from "common/src/helpers";

const ActionButtons = styled(Dialog.ActionButtons)`
justify-content: end;
Expand Down Expand Up @@ -180,14 +181,19 @@ function DialogContent({ reservation, onClose, onReject }: Props): JSX.Element {
<Dialog.Content>
<Flex>
<Select
required
id="denyReason"
options={options}
placeholder={t("common.select")}
label={t("RequestedReservation.DenyDialog.denyReason")}
onChange={(v) => setDenyReason(Number(v))}
value={denyReasonPk}
helper={t("RequestedReservation.DenyDialog.denyReasonHelper")}
required
texts={{
placeholder: t("common.select"),
label: t("RequestedReservation.DenyDialog.denyReason"),
assistive :t("RequestedReservation.DenyDialog.denyReasonHelper"),

Check failure on line 189 in apps/admin-ui/src/component/DenyDialog.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Replace `·:` with `:·`
}}
options={options.map(convertOptionToHDS)}
value={denyReasonPk ? denyReasonPk.toString() : undefined}
onChange={(selected) => {
const v = selected.find(() => true)?.value;
setDenyReason(toNumber(v))

Check failure on line 195 in apps/admin-ui/src/component/DenyDialog.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Insert `;`
} }

Check failure on line 196 in apps/admin-ui/src/component/DenyDialog.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Delete `·`
/>
<TextArea
value={handlingDetails}
Expand All @@ -207,9 +213,8 @@ function DialogContent({ reservation, onClose, onReject }: Props): JSX.Element {
</Dialog.Content>
<ActionButtons>
<Button
variant="secondary"
variant={ButtonVariant.Secondary}
onClick={onClose}
theme="black"
data-testid="deny-dialog__cancel-button"
>
{t("common.prev")}
Expand Down
15 changes: 6 additions & 9 deletions apps/admin-ui/src/component/EditTimeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import { Button, Dialog, Notification } from "hds-react";
import { Button, ButtonSize, ButtonVariant, Dialog, Notification, NotificationSize } from "hds-react";

Check failure on line 4 in apps/admin-ui/src/component/EditTimeModal.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Replace `·Button,·ButtonSize,·ButtonVariant,·Dialog,·Notification,·NotificationSize·` with `⏎··Button,⏎··ButtonSize,⏎··ButtonVariant,⏎··Dialog,⏎··Notification,⏎··NotificationSize,⏎`
import { z } from "zod";
import { type TFunction } from "i18next";
import {
Expand Down Expand Up @@ -61,12 +61,6 @@ const StyledDialog = styled(Dialog)`
max-width: 944px;
`;

Check failure on line 62 in apps/admin-ui/src/component/EditTimeModal.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Delete `⏎`

const btnCommon = {
theme: "black",
size: "small",
variant: "secondary",
disabled: false,
} as const;

function recurringReservationInfoText({
weekdays,
Expand Down Expand Up @@ -280,7 +274,7 @@ function DialogContent({
</TimeInfoBox>
{hasCollisions && (
<Notification
size="small"
size={NotificationSize.Small}
label={t(`${commonTrKey}.error.reservationCollides`)}
type="error"
style={{ marginTop: "var(--spacing-s)", gridColumn: "1 / -1" }}
Expand All @@ -289,7 +283,10 @@ function DialogContent({
</Notification>
)}
<ActionButtons>
<Button {...btnCommon} onClick={onClose}>
<Button
size={ButtonSize.Small}
variant={ButtonVariant.Secondary}
onClick={onClose}>

Check failure on line 289 in apps/admin-ui/src/component/EditTimeModal.tsx

View workflow job for this annotation

GitHub Actions / Lint admin ui

Insert `⏎··········`
{t("common.cancel")}
</Button>
<Button disabled={isDisabled} type="submit">
Expand Down
4 changes: 2 additions & 2 deletions apps/admin-ui/src/component/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react";
import { IconLinkExternal } from "hds-react";
import { IconLinkExternal, IconSize } from "hds-react";
import styled from "styled-components";
import { fontMedium } from "common/src/common/typography";
import { Link } from "react-router-dom";

type Props = {
to: string;
children: string;
size?: "xs" | "s" | "m" | "l" | "xl";
size?: IconSize
isBold?: boolean;
};

Expand Down
4 changes: 2 additions & 2 deletions apps/admin-ui/src/component/LinkPrev.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import { IconAngleLeft } from "hds-react";
import { IconAngleLeft, IconSize } from "hds-react";
import { Link } from "react-router-dom";

const StyledLink = styled(Link)`
Expand Down Expand Up @@ -32,7 +32,7 @@ function LinkPrevInner({ route, style, className }: Props): JSX.Element {
className={className}
data-testid="link__previous"
>
<IconAngleLeft size="s" aria-hidden />
<IconAngleLeft size={IconSize.Small} aria-hidden="true" />
{t("common.prev")}
</StyledLink>
);
Expand Down
8 changes: 5 additions & 3 deletions apps/admin-ui/src/component/More.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import styled from "styled-components";
import { Button } from "hds-react";
import { Button, ButtonVariant } from "hds-react";
import { useTranslation } from "react-i18next";
import type { ApolloQueryResult } from "@apollo/client";
import type { PageInfo, Query } from "@gql/gql-types";
Expand Down Expand Up @@ -45,8 +45,10 @@ export function More({
})}
</Counts>
<Button
isLoading={isFetching}
variant="secondary"
// FIXME
// isLoading={isFetching}
variant={ButtonVariant.Secondary}
disabled={isFetching}
onClick={handleClick}
>
{t("common.showMore")}
Expand Down
3 changes: 2 additions & 1 deletion apps/admin-ui/src/component/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IconSignout,
IconStar,
IconUser,
LogoSize,
TitleStyleType,
} from "hds-react";
import React from "react";
Expand Down Expand Up @@ -281,7 +282,7 @@ const Navigation = ({ apiBaseUrl }: Props) => {
titleStyle={TitleStyleType.Bold}
titleHref={env.NEXT_PUBLIC_BASE_URL ?? "/"}
openFrontPageLinksAriaLabel={t("common:applicationName")}
logo={<Logo size="large" style={{ filter: "invert(1)" }} />}
logo={<Logo size={LogoSize.Large} style={{ filter: "invert(1)" }} />}
logoAriaLabel={`${t("common:applicationName")} logo`}
logoHref={env.NEXT_PUBLIC_BASE_URL}
>
Expand Down
61 changes: 0 additions & 61 deletions apps/admin-ui/src/component/QueryParamFilters/ComboboxFilter.tsx

This file was deleted.

16 changes: 7 additions & 9 deletions apps/admin-ui/src/component/QueryParamFilters/DayNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import styled from "styled-components";
import { addDays, subDays } from "date-fns";
import { useTranslation } from "next-i18next";
import { Button, IconAngleLeft, IconAngleRight, DateInput } from "hds-react";
import { Button, IconAngleLeft, IconAngleRight, DateInput, ButtonSize, ButtonVariant } from "hds-react";
import { fromUIDate, toUIDate } from "common/src/common/util";
import { breakpoints } from "common";
import { toMondayFirstUnsafe } from "common/src/helpers";
Expand Down Expand Up @@ -80,11 +80,10 @@ export function DayNavigation({ name }: Props): JSX.Element {
<Wrapper>
<Button
aria-label={t("common.prev")}
size="small"
variant="supplementary"
theme="black"
size={ButtonSize.Small}
variant={ButtonVariant.Supplementary}
onClick={onPreviousDay}
iconLeft={<IconAngleLeft />}
iconStart={<IconAngleLeft aria-hidden="true" />}
>
{" "}
</Button>
Expand All @@ -100,11 +99,10 @@ export function DayNavigation({ name }: Props): JSX.Element {
/>
<Button
aria-label={t("common.next")}
size="small"
variant="supplementary"
theme="black"
size={ButtonSize.Small}
variant={ButtonVariant.Supplementary}
onClick={onNextDay}
iconLeft={<IconAngleRight />}
iconStart={<IconAngleRight aria-hidden="true" />}
>
{" "}
</Button>
Expand Down
Loading

0 comments on commit a853e8c

Please sign in to comment.