Skip to content

Commit afa9673

Browse files
Use LinkComponent prop in Breadcrumbs & reorganise components
1 parent 54a84bb commit afa9673

33 files changed

+273
-290
lines changed

.storybook/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const config: StorybookConfig = {
99
"@storybook/addon-interactions",
1010
"@storybook/addon-links",
1111
"storybook-dark-mode",
12-
"storybook-addon-remix-react-router",
1312
],
1413
framework: {
1514
name: "@storybook/react-webpack5",

.storybook/preview.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import { CssBaseline } from "@mui/material";
33
import type { Preview } from "@storybook/react";
4-
import { withRouter } from "storybook-addon-remix-react-router";
54

65
import { ThemeProvider } from "../src";
76
import { GenericTheme, DiamondTheme } from "../src";
@@ -12,7 +11,6 @@ const TextThemeBase = "Theme: Generic";
1211
const TextThemeDiamond = "Theme: Diamond";
1312

1413
export const decorators = [
15-
withRouter,
1614
(StoriesWithPadding: React.FC) => {
1715
return (
1816
<div style={{ padding: "2em" }}>
@@ -78,6 +76,11 @@ const preview: Preview = {
7876
backgrounds: { disable: true },
7977
layout: "fullscreen",
8078
},
79+
argTypes: {
80+
linkComponent: {
81+
control: false,
82+
},
83+
},
8184
};
8285

8386
export default preview;

changelog.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ SciReactUI Changelog
22
====================
33

44

5-
[v0.1.1] - 2025-?-?
5+
[v0.2.0] - 2025-?-?
66
--------------------
77

88
### Added
9-
- SciReactUIProvider to use ThemeProvider and BrowserRouter.
9+
-
1010

1111
### Fixed
1212
- Styles added to Navbar and Footer incorrectly remove built in styles.
1313

1414
### Changed
15-
- Breadcrumbs component uses react-router-dom for page routing.
15+
- Breaking change Breadcrumbs component requires linkComponent prop for page routing.
1616

1717
[v0.1.0] - 2025-04-10
1818
---------------------

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default [
4141
},
4242
rules: {
4343
"react/react-in-jsx-scope": "off",
44+
"react/prop-types": "off",
4445
"no-console": "off",
4546
"prettier/prettier": "error",
4647
"@typescript-eslint/no-unused-vars": [

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@diamondlightsource/sci-react-ui",
3-
"version": "0.1.1alpha",
3+
"version": "0.2",
44
"description": "A theme and component library to make websites at scientific institutions simple to create.",
55
"author": "Diamond Light Source",
66
"license": "ISC",
@@ -31,9 +31,7 @@
3131
"@emotion/styled": "^11.13.0",
3232
"@mui/icons-material": "^6.1.7",
3333
"@mui/material": "^6.1.7",
34-
"react": "^18.3.1",
35-
"react-dom": "^18.3.1",
36-
"react-router-dom": "^7.5.3"
34+
"react": "^18.3.1"
3735
},
3836
"devDependencies": {
3937
"@babel/core": "^7.26.0",
@@ -78,12 +76,13 @@
7876
"jest": "^29.7.0",
7977
"jest-environment-jsdom": "^29.7.0",
8078
"jest-transform-stub": "^2.0.0",
79+
"react-dom": "^18.3.1",
80+
"react-router-dom": "^7.5.3",
8181
"rollup": "^4.27.3",
8282
"rollup-plugin-dts": "^6.1.1",
8383
"rollup-plugin-peer-deps-external": "^2.2.4",
8484
"rollup-plugin-postcss": "^4.0.2",
8585
"storybook": "^8.4.4",
86-
"storybook-addon-remix-react-router": "3",
8786
"storybook-dark-mode": "^4.0.2",
8887
"tslib": "^2.8.1",
8988
"typescript": "^5.6.3",

pnpm-lock.yaml

Lines changed: 6 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,78 @@ npm i @diamondlightsource/sci-react-ui
1919

2020
### Usage
2121

22-
First use SciReactUIProvider and supply a theme to use the ThemeProvider and BrowserRouter.
22+
First use the ThemeProvider and supply a theme.
2323

2424
```js
25+
import { ThemeProvider, DiamondTheme } from "@diamondlightsource/sci-react-ui";
26+
27+
root.render(
28+
<ThemeProvider theme={DiamondTheme}>
29+
<App />
30+
</ThemeProvider>,
31+
);
32+
```
33+
34+
There are currently two themes, `GenericTheme` or `DiamondTheme`, but you can - and should - adapt your own.
35+
36+
To use the Breadcrumbs component, use a route provider from your preferred library. For example, to use react-router's BrowserRouter, install react-router-dom:
37+
38+
```sh
39+
npm i react-router-dom
40+
```
41+
42+
Next, use the BrowserRouter which can be used at the top level:
43+
44+
```js
45+
import { BrowserRouter } from "react-router-dom";
2546
import {
26-
SciReactUIProvider,
47+
ThemeProvider,
2748
DiamondTheme
2849
} from "@diamondlightsource/sci-react-ui";
2950

3051
root.render(
31-
<SciReactUIProvider theme={DiamondTheme}>
32-
<App />
33-
</SciReactUIProvider>
52+
<ThemeProvider theme={DiamondTheme}>
53+
<BrowserRouter>
54+
<App />
55+
<BrowserRouter>
56+
</ThemeProvider>
3457
)
3558
```
3659

37-
There are currently two themes, `GenericTheme` or `DiamondTheme`, but you can - and should - adapt your own.
60+
Then pass your library's corresponding Link component to Breadcrumbs, for example:
3861

39-
There are various components, here's an example of how to use the NavBar:
62+
```js
63+
import { Link } from "react-router-dom";
64+
import { Breadcrumbs } from "@diamondlightsource/sci-react-ui";
65+
66+
function App() {
67+
return <Breadcrumbs path={window.location.pathname} linkComponent={Link} />;
68+
}
69+
export default App;
70+
```
71+
72+
There are various other components, here's an example of how to use the NavBar:
4073

4174
```js
42-
import {Container, Typography} from "@mui/material";
43-
import {
44-
Navbar,
45-
NavLink,
46-
NavLinks
47-
} from "@diamondlightsource/sci-react-ui";
75+
import { Container, Typography } from "@mui/material";
76+
import { Navbar, NavLink, NavLinks } from "@diamondlightsource/sci-react-ui";
4877

4978
function App() {
50-
return <>
51-
<Navbar>
52-
<NavLinks key="links">
53-
<NavLink href="#" key="first">A link</NavLink>
54-
</NavLinks>
55-
</Navbar>
56-
<Container>
57-
<Typography variant="h2">Scientific UI Collection</Typography>
58-
<Typography>A collection of science based React components.</Typography>
59-
</Container>
60-
</>
79+
return (
80+
<>
81+
<Navbar>
82+
<NavLinks key="links">
83+
<NavLink href="#" key="first">
84+
A link
85+
</NavLink>
86+
</NavLinks>
87+
</Navbar>
88+
<Container>
89+
<Typography variant="h2">Scientific UI Collection</Typography>
90+
<Typography>A collection of science based React components.</Typography>
91+
</Container>
92+
</>
93+
);
6194
}
6295
export default App;
6396
```

0 commit comments

Comments
 (0)