Skip to content

Commit

Permalink
refactor: [M3-8640] – Move Theme layer from manager package to ui
Browse files Browse the repository at this point in the history
… package (#11092)
  • Loading branch information
dwiley-akamai authored Oct 15, 2024
1 parent 8621de3 commit f6f5e97
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 45 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ x-e2e-volumes:
&default-volumes
- ./.git:/home/node/app/.git
- ./cache:/home/node/app/cache
- ./packages/manager:/home/node/app/packages/manager
- ./packages/validation:/home/node/app/packages/validation
- ./packages/api-v4:/home/node/app/packages/api-v4
- ./packages:/home/node/app/packages
- ./package.json:/home/node/app/package.json
- ./node_modules:/home/node/app/node_modules

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Moved `src/foundations` directory from `manager` package to new `ui` package ([#11092](https://github.com/linode/manager/pull/11092))
19 changes: 9 additions & 10 deletions packages/manager/cypress/support/component/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@
// https://on.cypress.io/configuration
// ***********************************************************

import * as React from 'react';
import { queryClientFactory } from '@src/queries/base';
import { QueryClientProvider } from '@tanstack/react-query';
import '@testing-library/cypress/add-commands';
import 'cypress-axe';
import { mount } from 'cypress/react18';

import { Provider } from 'react-redux';
import { LDProvider } from 'launchdarkly-react-client-sdk';
import { QueryClientProvider } from '@tanstack/react-query';
import { queryClientFactory } from '@src/queries/base';
import { LinodeThemeWrapper } from 'src/LinodeThemeWrapper';
import { SnackbarProvider } from 'notistack';
import * as React from 'react';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import { storeFactory } from 'src/store';

import '@testing-library/cypress/add-commands';
import { ThemeName } from 'src/foundations/themes';
import { LinodeThemeWrapper } from 'src/LinodeThemeWrapper';
import { storeFactory } from 'src/store';

import 'cypress-axe';
import type { ThemeName } from '@linode/ui';

/**
* Mounts a component with a Cloud Manager theme applied.
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/cypress/support/util/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file Utilities for component testing.
*/

import { MountReturn } from 'cypress/react18';
import type { ThemeName } from 'src/foundations/themes';
import type { ThemeName } from '@linode/ui';
import type { MountReturn } from 'cypress/react18';

/**
* Array of themes for which to test components.
Expand Down
3 changes: 2 additions & 1 deletion packages/manager/src/LinodeThemeWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { StyledEngineProvider, ThemeProvider } from '@mui/material/styles';
import * as React from 'react';

import { ThemeName } from './foundations/themes';
import { themes, useColorMode } from './utilities/theme';

import type { ThemeName } from '@linode/ui';

interface Props {
children: React.ReactNode;
/** Allows theme to be overwritten. Used for Storybook theme switching */
Expand Down
3 changes: 1 addition & 2 deletions packages/manager/src/components/Button/StyledActionButton.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { latoWeb } from '@linode/ui';
import { styled } from '@mui/material/styles';

import { latoWeb } from 'src/foundations/fonts';

import { Button } from './Button';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { unsafe_MarkdownIt } from 'src/utilities/markdown';
import { sanitizeHTML } from 'src/utilities/sanitizeHTML';
import { useColorMode } from 'src/utilities/theme';

import type { ThemeName } from 'src/foundations/themes';
import type { ThemeName } from '@linode/ui';
import type { SanitizeOptions } from 'src/utilities/sanitizeHTML';

hljs.registerLanguage('apache', apache);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { breakpoints } from '@linode/ui';
import { fireEvent, screen } from '@testing-library/react';
import React from 'react';

import { breakpoints } from 'src/foundations/breakpoints';
import { renderWithTheme, resizeScreenSize } from 'src/utilities/testHelpers';

import { SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_WIDTH, SideMenu } from './SideMenu';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { breakpoints } from '@linode/ui';
import { fireEvent, render, waitFor } from '@testing-library/react';
import * as React from 'react';

import { extendedTypeFactory } from 'src/factories/types';
import { LIMITED_AVAILABILITY_COPY } from 'src/features/components/PlansPanel/constants';
import { breakpoints } from 'src/foundations/breakpoints';
import { PlanWithAvailability } from 'src/features/components/PlansPanel/types';
import {
renderWithTheme,
resizeScreenSize,
wrapWithTableBody,
} from 'src/utilities/testHelpers';

import {
KubernetesPlanSelection,
KubernetesPlanSelectionProps,
} from './KubernetesPlanSelection';
import { KubernetesPlanSelection } from './KubernetesPlanSelection';

import type { PlanWithAvailability } from 'src/features/components/PlansPanel/types';
import type { KubernetesPlanSelectionProps } from './KubernetesPlanSelection';

const planHeader = 'Dedicated 20 GB';
const baseHourlyPrice = '$0.015';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { inputMaxWidth } from '@linode/ui';
import React from 'react';
import { Controller, useFormContext, useWatch } from 'react-hook-form';

Expand All @@ -15,7 +16,6 @@ import { Paper } from 'src/components/Paper';
import { getIsDistributedRegion } from 'src/components/RegionSelect/RegionSelect.utils';
import { Skeleton } from 'src/components/Skeleton';
import { Typography } from 'src/components/Typography';
import { inputMaxWidth } from 'src/foundations/themes/light';
import { useRestrictedGlobalGrantCheck } from 'src/hooks/useRestrictedGlobalGrantCheck';
import { useRegionsQuery } from 'src/queries/regions/regions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { inputMaxWidth } from '@linode/ui';
import React, { useState } from 'react';
import { Controller, useFormContext, useWatch } from 'react-hook-form';

Expand All @@ -20,7 +21,6 @@ import {
VPC_AUTO_ASSIGN_IPV4_TOOLTIP,
} from 'src/features/VPCs/constants';
import { VPCCreateDrawer } from 'src/features/VPCs/VPCCreateDrawer/VPCCreateDrawer';
import { inputMaxWidth } from 'src/foundations/themes/light';
import { useRegionsQuery } from 'src/queries/regions/regions';
import { useVPCQuery, useVPCsQuery } from 'src/queries/vpcs/vpcs';
import { sendLinodeCreateFormInputEvent } from 'src/utilities/analytics/formEventAnalytics';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { breakpoints } from '@linode/ui';
import userEvent from '@testing-library/user-event';
import * as React from 'react';

import { nodeBalancerFactory } from 'src/factories';
import { breakpoints } from 'src/foundations/breakpoints';
import { useIsResourceRestricted } from 'src/hooks/useIsResourceRestricted';
import { renderWithTheme, resizeScreenSize } from 'src/utilities/testHelpers';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { breakpoints } from '@linode/ui';
import { render, screen } from '@testing-library/react';
import * as React from 'react';

import {
supportReplyFactory,
supportTicketFactory,
} from 'src/factories/support';
import { breakpoints } from 'src/foundations/breakpoints';
import { makeResourcePage } from 'src/mocks/serverHandlers';
import { HttpResponse, http, server } from 'src/mocks/testServer';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { breakpoints } from '@linode/ui';
import { fireEvent, waitFor } from '@testing-library/react';
import React from 'react';

Expand All @@ -6,10 +7,9 @@ import {
planSelectionTypeFactory,
} from 'src/factories/types';
import { LIMITED_AVAILABILITY_COPY } from 'src/features/components/PlansPanel/constants';
import { breakpoints } from 'src/foundations/breakpoints';
import { renderWithTheme } from 'src/utilities/testHelpers';
import { resizeScreenSize } from 'src/utilities/testHelpers';
import { wrapWithTableBody } from 'src/utilities/testHelpers';
import { renderWithTheme } from 'src/utilities/testHelpers';

import { PlanSelection } from './PlanSelection';

Expand Down
8 changes: 4 additions & 4 deletions packages/manager/src/utilities/theme.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Theme } from '@mui/material/styles';
import { dark, light } from '@linode/ui';
import useMediaQuery from '@mui/material/useMediaQuery';

import { dark, light } from 'src/foundations/themes';

import type { ThemeName } from 'src/foundations/themes';
import { useAuthentication } from 'src/hooks/useAuthentication';
import { usePreferences } from 'src/queries/profile/preferences';

import type { ThemeName } from '@linode/ui';
import type { Theme } from '@mui/material/styles';

export type ThemeChoice = 'dark' | 'light' | 'system';

export const themes: Record<ThemeName, Theme> = { dark, light };
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/.changeset/pr-11092-added-1728931799888.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/ui": Added
---

Themes, fonts, and breakpoints previously located in `manager` package ([#11092](https://github.com/linode/manager/pull/11092))
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/ui/src/foundations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './breakpoints';
export * from './fonts';
export * from './themes';
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
TextField,
} from '@linode/design-language-system/themes/dark';

import { breakpoints } from 'src/foundations/breakpoints';
import { latoWeb } from 'src/foundations/fonts';
import { breakpoints } from '../breakpoints';
import { latoWeb } from '../fonts';

import type { ThemeOptions } from '@mui/material/styles';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { createTheme } from '@mui/material/styles';

// Themes & Brands
import { darkTheme } from 'src/foundations/themes/dark';
import { lightTheme } from 'src/foundations/themes/light';
import { darkTheme } from './dark';
import { lightTheme, inputMaxWidth as _inputMaxWidth } from './light';

import type {
ChartTypes,
InteractionTypes as InteractionTypesLight,
} from '@linode/design-language-system';
import type { InteractionTypes as InteractionTypesDark } from '@linode/design-language-system/themes/dark';
import type { latoWeb } from 'src/foundations/fonts';
import type { latoWeb } from '../fonts';
// Types & Interfaces
import type {
customDarkModeOptions,
notificationToast as notificationToastDark,
} from 'src/foundations/themes/dark';
} from './dark';
import type {
bg,
borderColors,
color,
notificationToast,
textColors,
} from 'src/foundations/themes/light';
} from './light';

export type ThemeName = 'dark' | 'light';

Expand Down Expand Up @@ -105,5 +105,6 @@ declare module '@mui/material/styles/createTheme' {
}
}

export const inputMaxWidth = _inputMaxWidth;
export const light = createTheme(lightTheme);
export const dark = createTheme(lightTheme, darkTheme);
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
Select,
} from '@linode/design-language-system';

import { breakpoints } from 'src/foundations/breakpoints';
import { latoWeb } from 'src/foundations/fonts';
import { breakpoints } from '../breakpoints';
import { latoWeb } from '../fonts';

import type { ThemeOptions } from '@mui/material/styles';

Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './components';
export * from './foundations';

0 comments on commit f6f5e97

Please sign in to comment.