-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(breadcrumb): reset is-last attribute on new items setup
- Loading branch information
Showing
17 changed files
with
238 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
.app { | ||
font-family: var(--ods-font-family-default); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { App } from 'app/App'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
// import { App } from 'app/App'; | ||
import { RouterApp } from 'router-app/RouterApp'; | ||
// import '@ovhcloud/ods-themes/dark'; | ||
import '@ovhcloud/ods-themes/default'; | ||
|
||
const appElement = document.getElementById('app'); | ||
const root = createRoot(appElement!); | ||
|
||
function renderApp() { | ||
// function renderApp() { | ||
// root.render( | ||
// <App />, | ||
// ); | ||
// } | ||
|
||
function renderRouterApp() { | ||
root.render( | ||
<App />, | ||
<BrowserRouter> | ||
<RouterApp /> | ||
</BrowserRouter> | ||
); | ||
} | ||
|
||
renderApp(); | ||
//renderApp(); | ||
renderRouterApp(); |
21 changes: 21 additions & 0 deletions
21
packages/examples/react-webpack/src/router-app/RouterApp.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { type ReactElement } from 'react'; | ||
import { Navigate, Route, Routes } from 'react-router-dom'; | ||
import { Breadcrumb } from 'router-app/components/breadcrumb/Breadcrumb'; | ||
import { ROUTE } from 'router-app/constants/navigation'; | ||
import { Products } from 'router-app/modules/products/Products'; | ||
import styles from './routerApp.scss'; | ||
|
||
function RouterApp(): ReactElement { | ||
return ( | ||
<div className={ styles['router-app'] }> | ||
<Breadcrumb /> | ||
|
||
<Routes> | ||
<Route path={ `${ROUTE.products}/*` } element={ <Products /> } /> | ||
<Route path="*" element={ <Navigate to={ ROUTE.products } replace /> } /> | ||
</Routes> | ||
</div> | ||
); | ||
} | ||
|
||
export { RouterApp }; |
38 changes: 38 additions & 0 deletions
38
packages/examples/react-webpack/src/router-app/components/breadcrumb/Breadcrumb.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { OdsBreadcrumb, OdsBreadcrumbItem } from '@ovhcloud/ods-components/react'; | ||
import React, { type ReactElement, useEffect, useState } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import styles from './breadcrumb.scss'; | ||
|
||
function Breadcrumb (): ReactElement { | ||
const location = useLocation(); | ||
const [items, setItems] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
const pathParts = location.pathname.split('/').filter(Boolean); | ||
let lastPath = ''; | ||
|
||
setItems(pathParts.map((pathPart) => { | ||
lastPath += `/${pathPart}`; | ||
|
||
return { | ||
href: lastPath, | ||
label: pathPart, | ||
}; | ||
})); | ||
}, [location.pathname]); | ||
|
||
return ( | ||
<OdsBreadcrumb> | ||
{ | ||
items.map((item: any) => ( | ||
<OdsBreadcrumbItem className={ styles['breadcrumb__item'] } | ||
key={ item.href } | ||
href={ item.href } | ||
label={ item.label } /> | ||
)) | ||
} | ||
</OdsBreadcrumb> | ||
); | ||
} | ||
|
||
export { Breadcrumb }; |
5 changes: 5 additions & 0 deletions
5
packages/examples/react-webpack/src/router-app/components/breadcrumb/breadcrumb.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.breadcrumb { | ||
&__item { | ||
text-transform: capitalize; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/examples/react-webpack/src/router-app/constants/navigation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
enum ROUTE { | ||
products = '/products' | ||
} | ||
|
||
export { | ||
ROUTE, | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages/examples/react-webpack/src/router-app/modules/products/Products.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { type ReactElement } from 'react'; | ||
import { Navigate, Route, Routes } from 'react-router-dom'; | ||
import { ROUTE } from 'router-app/constants/navigation'; | ||
import { Home } from 'router-app/modules/products/modules/home/Home'; | ||
import { List } from 'router-app/modules/products/modules/list/List'; | ||
import { View } from 'router-app/modules/products/modules/view/View'; | ||
|
||
function Products(): ReactElement { | ||
return ( | ||
<Routes> | ||
<Route path="list" element={ <List /> } /> | ||
<Route path="list/*" element={ <View /> } /> | ||
<Route index element={ <Home /> } /> | ||
<Route path="*" element={ <Navigate to={ ROUTE.products } replace /> } /> | ||
</Routes> | ||
); | ||
} | ||
|
||
export { Products }; |
19 changes: 19 additions & 0 deletions
19
packages/examples/react-webpack/src/router-app/modules/products/modules/home/Home.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { type ReactElement } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { ROUTE } from 'router-app/constants/navigation'; | ||
|
||
function Home(): ReactElement { | ||
return ( | ||
<div> | ||
<h1> | ||
Products Home Page | ||
</h1> | ||
|
||
<Link to={ `${ROUTE.products}/list` }> | ||
Go to list page | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export { Home }; |
31 changes: 31 additions & 0 deletions
31
packages/examples/react-webpack/src/router-app/modules/products/modules/list/List.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { type ReactElement } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { ROUTE } from 'router-app/constants/navigation'; | ||
|
||
function List(): ReactElement { | ||
return ( | ||
<div> | ||
<h1> | ||
Products List Page | ||
</h1> | ||
|
||
<Link to={ ROUTE.products }> | ||
Back | ||
</Link> | ||
|
||
<br /> | ||
|
||
<Link to={ `${ROUTE.products}/list/product1` }> | ||
View product 1 | ||
</Link> | ||
|
||
<br /> | ||
|
||
<Link to={ `${ROUTE.products}/list/product2` }> | ||
View product 2 | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export { List }; |
19 changes: 19 additions & 0 deletions
19
packages/examples/react-webpack/src/router-app/modules/products/modules/view/View.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { type ReactElement } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { ROUTE } from 'router-app/constants/navigation'; | ||
|
||
function View(): ReactElement { | ||
return ( | ||
<div> | ||
<h1> | ||
Products View Page | ||
</h1> | ||
|
||
<Link to={ `${ROUTE.products}/list` }> | ||
Back | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export { View }; |
5 changes: 5 additions & 0 deletions
5
packages/examples/react-webpack/src/router-app/routerApp.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// @import '@ovhcloud/ods-components/style'; | ||
|
||
.router-app { | ||
font-family: var(--ods-font-family-default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters