5.0.9 • Published 19 days ago

@tdcerhverv/mui-theme v5.0.9

Weekly downloads
258
License
-
Repository
github
Last release
19 days ago

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.

5.0.9

19 days ago

5.0.8

2 months ago

5.0.7

8 months ago

5.0.6

8 months ago

5.0.5

9 months ago

5.0.4

9 months ago

4.0.1

1 year ago

5.0.3

1 year ago

5.0.2

1 year ago

5.0.1

1 year ago

4.0.0

1 year ago

3.24.0

1 year ago

3.24.1

1 year ago

3.23.1

2 years ago

3.23.3

2 years ago

3.23.2

2 years ago

3.23.4

2 years ago

3.23.0

2 years ago

3.22.0

2 years ago

3.21.0

2 years ago

3.20.1

2 years ago

3.19.0

2 years ago

3.18.1

2 years ago

3.18.0

2 years ago

3.17.3

2 years ago

3.17.0

2 years ago

3.17.2

2 years ago

3.17.1

2 years ago

3.15.0

2 years ago

3.15.2

2 years ago

3.15.1

2 years ago

3.15.3

2 years ago

3.12.1

2 years ago

3.12.0

2 years ago

3.14.1

2 years ago

3.14.0

2 years ago

3.12.2

2 years ago

3.16.0

2 years ago

3.14.2

2 years ago

3.13.0

2 years ago

3.11.15

2 years ago

3.11.14

2 years ago

3.11.4

2 years ago

3.11.6

2 years ago

3.11.5

2 years ago

3.11.8

2 years ago

3.11.7

2 years ago

3.11.9

2 years ago

3.11.11

2 years ago

3.11.10

2 years ago

3.11.13

2 years ago

3.11.12

2 years ago

3.11.3

3 years ago

3.11.0

3 years ago

3.11.2

3 years ago

3.11.1

3 years ago

3.9.0

3 years ago

3.10.0

3 years ago

3.8.1

3 years ago

3.8.0

3 years ago

3.7.1

3 years ago

3.7.0

3 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.4.0

3 years ago

3.4.3

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.3.7

3 years ago

3.3.6

3 years ago

3.3.1

3 years ago

3.3.5

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.0

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.0-beta.1

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

2.0.0-alpha.2

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago