-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
287 additions
and
130 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 |
---|---|---|
@@ -1,6 +1,25 @@ | ||
/* (C) Copyright 2024 Dassault Systemes SE. All Rights Reserved. */ | ||
.ContainerSM { | ||
.NuoContainerSM { | ||
max-width: 600px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
.NuoBanner { | ||
width: 100%; | ||
padding-left: 24px; | ||
padding-right: 24px; | ||
background-color: rgb(25, 118, 210); | ||
box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px; | ||
color: white; | ||
position: static; | ||
} | ||
|
||
.NuoBannerItems { | ||
flex: 1 0 auto; | ||
display: flex; | ||
} | ||
|
||
.NuoBannerSettings { | ||
flex: 0 0 auto; | ||
display: flex; | ||
} |
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,4 +1,7 @@ | ||
/* (C) Copyright 2024 Dassault Systemes SE. All Rights Reserved. */ | ||
.BannerItem { | ||
color: white !important; | ||
} | ||
.NuoBannerMenu>button { | ||
color: white !important; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// (C) Copyright 2024 Dassault Systemes SE. All Rights Reserved. | ||
|
||
import { ReactNode, useState } from 'react'; | ||
import { isMaterial } from '../../utils/Customizations'; | ||
import { Menu as MuiMenu } from '@mui/material'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import Button from './Button'; | ||
|
||
type MenuItemProps = { | ||
id: string, | ||
label: string, | ||
onClick: () => void | ||
} | ||
|
||
type MenuItemsProps = MenuItemProps[]; | ||
|
||
type MenuProps = { | ||
"data-testid"?: string, | ||
align?: "left" | "right", | ||
children?: ReactNode, | ||
items: MenuItemsProps, | ||
className?: string | ||
}; | ||
|
||
export default function Menu(props: MenuProps): JSX.Element { | ||
const { align, children, items, className } = props; | ||
const [anchor, setAnchor] = useState<Element | null>(null); | ||
|
||
function popupMenu(items: MenuItemsProps) { | ||
if (isMaterial()) { | ||
return <MuiMenu | ||
sx={{ mt: '5px' }} | ||
id="menu-appbar" | ||
anchorEl={anchor} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: align || 'right', | ||
}} | ||
keepMounted | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: align || 'right', | ||
}} | ||
open={Boolean(anchor)} | ||
onClose={() => setAnchor(null)} | ||
> | ||
{items.map(item => <MenuItem key={item.id} data-testid={item.id} onClick={() => { | ||
setAnchor(null); | ||
item.onClick(); | ||
}}>{item.label}</MenuItem>)} | ||
</MuiMenu>; | ||
} | ||
const rect = anchor?.getBoundingClientRect(); | ||
const x = align === "right" ? rect?.right : rect?.left; | ||
return <div style={{ display: anchor ? "block" : "none", position: "fixed", right: 0, left: 0, top: 0, bottom: 0, backgroundColor: "transparent" }} onClick={() => setAnchor(null)}> | ||
<div style={{ position: "absolute", right: x, left: x, top: rect?.bottom, bottom: rect?.bottom }}> | ||
<ul id="NuoMenuPopup" className={"NuoMenuPopup " + (align === "right" ? " NuoAlignRight" : " NuoAlignLeft")}> | ||
{items.map(item => <li key={item.id} className="NuoMenuPopupItem" onClick={() => item.onClick()}>{item.label}</li>)} | ||
</ul></div> | ||
</div>; | ||
} | ||
|
||
function listMenu(items: MenuItemsProps) { | ||
return items.map((item, index) => <Button | ||
data-testid={item.id} | ||
key={item.id} | ||
onClick={item.onClick} | ||
> | ||
{item.label} | ||
</Button>); | ||
} | ||
|
||
if (children) { | ||
return <> | ||
<div className="NuoMenuToggle" onClick={(event) => { | ||
setAnchor(event.currentTarget) | ||
}}><>{children}</></div> | ||
{popupMenu(items)} | ||
</>; | ||
} | ||
else { | ||
return <div className={className}>{listMenu(items)}</div>; | ||
} | ||
} |
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,48 @@ | ||
// (C) Copyright 2024 Dassault Systemes SE. All Rights Reserved. | ||
|
||
import { isMaterial } from '../../utils/Customizations'; | ||
import { Pagination as MuiPagination, Stack as MuiStack } from '@mui/material'; | ||
|
||
export type PaginationProps = { | ||
"data-testid"?: string, | ||
count: number, | ||
page: number, | ||
setPage: (page: number) => void | ||
} | ||
export default function Pagination(props: PaginationProps): JSX.Element | null { | ||
const { count, page, setPage } = props; | ||
|
||
if (count === 0) { | ||
return null; | ||
} | ||
|
||
if (isMaterial()) { | ||
return <MuiStack spacing={2} style={{ alignItems: "center" }}> | ||
<MuiPagination count={count} page={page} onChange={(event, page) => { | ||
props.setPage(page); | ||
}} /> | ||
</MuiStack> | ||
} | ||
else { | ||
return <div className="NuoPagination"> | ||
<div className="NuoPaginationItem NuoPaginationItemFirst" onClick={() => setPage(1)}><</div> | ||
{Array(count).fill(1).map((_, index) => { | ||
let className = "NuoPaginationItem"; | ||
if (page === index + 1) { | ||
className += " NuoPaginationItemSelected"; | ||
} | ||
if (page === 1) { | ||
className += " NuoPaginationItemFirst"; | ||
} | ||
if (page === count) { | ||
className += " NuoPaginationItemLast"; | ||
} | ||
|
||
return <div key={index} className={className} onClick={() => { | ||
setPage(index + 1) | ||
}}>{index + 1}</div> | ||
})} | ||
<div className="NuoPaginationItem NuoPaginationItemLast" onClick={() => setPage(count)}>></div> | ||
</div>; | ||
} | ||
} |
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
Oops, something went wrong.