@tdcerhverv/mui-theme
TypeScript icon, indicating that this package has built-in type declarations

5.3.7 • Public • Published

TDC Erhverv Material UI Theme

TDC Erhverv component styles for Material UI Components

The design specifications for components can be found on Figma.

The UX specifcations and use cases of the components can be found on ZeroHeight.

The styled components can be previewed on both Storybook and Chromatic

Setup

The package can be installed via NPM

npm i @tdcerhverv/mui-theme

Usage

This package is intendid to be used with Material-UI components and a ThemeProvider. With this wrapper you should be able to develop your application with the theme styling using Material-UI components out of the box.

Furthermore the <CssBaseline/> component should be included inside the <ThemeProvider/> before your app. For further information on <CssBaseline/>, please refer to Material-UI's documentation.

import { ThemeProvider } from '@mui/material/styles';
import TdcTheme from '@tdcerhverv/mui-theme';
import { CssBaseline } from '@mui/material';

export function App() {
    ReactDOM.render(
        <ThemeProvider theme={TdcTheme}>
            <CssBaseline />
            <App />
        </ThemeProvider>,
    );
}

Fonts

Pimarily the font used in the theme is "Mukta Mahee" and is included through the http://s.c.dk CDN.

In order to load fonts faster you should preload the fonts from the CDN.

<link rel="preload" href="//s.c.dk/fonts/mukta-mahee/mukta-mahee-latin-300-normal.woff2" as="font" crossorigin />
<link rel="preload" href="//s.c.dk/fonts/mukta-mahee/mukta-mahee-latin-500-normal.woff2" as="font" crossorigin />
<link rel="preload" href="//s.c.dk/fonts/mukta-mahee/mukta-mahee-latin-600-normal.woff2" as="font" crossorigin />

You will probably need the crossorigin attribute otherwise the browser will ignore the preload requested from a different domain.

The crossorigin attribute indicates whether the resource should be fetched with a CORS request as the font may come from a different domain. Without this attribute, the preloaded font is ignored by the browser. — https://web.dev/codelab-preload-web-fonts/#preloading-web-fonts

Variants

Some components offer custom variations of their styling, these are called Variants. An example of this is the Alert component, which has a variant called InlineAnnouncement that has a bottom border.

The base Alert component is created with the following:

<Alert severity="success" variant="standard">
    This is a message.
</Alert>

And the variant InlineAnnouncement uses a different class:

<Alert severity="info" variants="inline">
    This is a message.
</Alert>

Custom Variants

Custom variants are a way to create a new variant for any given componenet.

A custom variants are created in the following way:

Inside of the component file:

        variants: [
            {
                props: { variant: 'inline', severity: 'success' },
                style: {
                    padding: `4px 12px`,
                    backgroundColor: palette.success.contrastText,
                    borderBottom: `3px solid ${palette.success.dark}`,
                    ...shape,
                    '& .MuiAlert-icon': {
                        color: palette.success.dark,
                        '& > svg': {
                            width: 16,
                            height: 16,
                        },
                    },
                    '& .MuiAlert-message': {
                        color: palette.success.dark,
                        '& .MuiAlertTitle-root': {
                            ...typography.subtitle2,
                            marginBottom: 0,
                        },
                        '& .MuiLink-root': {
                            color: palette.success.dark,
                        },
                    },
                    '& .MuiAlert-action': {
                        color: palette.success.dark,
                    },
                },
            },
        ],

The variant prop will be the name of this new variant.

The severity prop in this case references a color from our palette.ts file, so you could have a variant that looks entirely based on the color given to it.

That would however require you to create another object in the variants array show in the example above.

In the global.d.ts file:

declare module '@mui/material/Alert' {
    interface AlertPropsVariantOverrides {
        inline: true;
    }
}

Declare the module inside of declare global.

Atomic Components

As of version 5.0.0 Atomic Components has been deleted.

Contributing

Please make sure that any and all changes suggested fulfill the following:

  • Styling on a specific material ui provided component
  • Suggested change has an agreed upon figma/zeroheight design
  • Change has a story if at all possible (some extremely small cases do not warrent a story (for example, FormLabel)

This package uses semantic pull-requests. PR titles should begin with the appropriate prefix, e.g. fix: or feat:. Branches should also follow this structure and be prefixed with fix/, feat/, or other relevant semantic label.

This repo uses the TDC Shared Components Jira board* for issue tracking. It is recommended to use the Jira Github integration for creating branches and pull requests. If you can't use this integration, then please refer to the Jira issue in the branch and PR name. For example the branch feat/SCP-123-my-feature should have a pull request titled feat: SCP-123 My Feature.

* Currently the Jira Github intergration does not apply Pull Request description templates. If using this integration, please add a description to your PR following the provided PR Template


You need two approvals on a PR, and both @nuuday/mdc-business, @nuuday/internet and Business Open Pages Review Group (https://github.com/orgs/nuuday/teams/business-open-pages-review-group/members) should be added as reviwers

In addition to regular Code Review, this Repo uses Chromatic for visual review. Chromatic will run a UI Test and UI Review on your PR. The UI Test will show you snapshots ofyour changes, and require you to approve or reject the changes.

When you are content with the changes in both UI Tests and Code Review, then you should open the UI Review, and assign a Designer as a reviewer in chromatic. Note that all assigned reviewers in chromatic must approve before the PR can be merged.

Coding rules

Font sizes should be defined with rem values using the pxToRem function. Spacing such as padding, margin etc. should be defined with fixed pixels values. You should avoid using the spacing function to have consistency in the code.

Readme

Keywords

none

Package Sidebar

Install

npm i @tdcerhverv/mui-theme

Weekly Downloads

234

Version

5.3.7

License

none

Unpacked Size

538 kB

Total Files

279

Last publish

Collaborators

  • antongb
  • dev_jonas
  • jeppebenjaminsen
  • ahhah
  • abdok
  • mikkv
  • clausr1990
  • tdc-sigbe
  • mdige
  • nuudaybot
  • tdc-olila
  • jeroen.dk.nl
  • renand
  • stegr
  • m84100
  • m92212
  • m87979
  • vertic
  • rasladev
  • muddz
  • tajsonik
  • linnt
  • molg