-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Fluent] DraggableLine, SpinButton/FLoatLineComponent, FileUploadLine with icon for NME #16876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sebavan
merged 4 commits into
BabylonJS:master
from
georginahalpern:numberAndFileComponents
Jul 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 19 additions & 10 deletions
29
packages/dev/sharedUiComponents/src/fluent/hoc/buttonLine.tsx
This file contains hidden or 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,33 +1,42 @@ | ||
import { Body1, Button, makeStyles, tokens } from "@fluentui/react-components"; | ||
import { Body1, Button as FluentButton, makeStyles, tokens } from "@fluentui/react-components"; | ||
import { LineContainer } from "./propertyLine"; | ||
import type { FunctionComponent } from "react"; | ||
import type { FluentIcon } from "@fluentui/react-icons"; | ||
|
||
const useButtonLineStyles = makeStyles({ | ||
button: { | ||
border: `1px solid ${tokens.colorBrandBackground}`, | ||
}, | ||
}); | ||
|
||
export type ButtonLineProps = { | ||
label: string; | ||
export type ButtonProps = { | ||
onClick: () => void; | ||
icon?: FluentIcon; | ||
label: string; | ||
disabled?: boolean; | ||
icon?: string; | ||
title?: string; | ||
}; | ||
|
||
/** | ||
* Wraps a button with a label in a line container | ||
* @param props Button props plus a label | ||
* @returns A button inside a line | ||
*/ | ||
export const ButtonLine: FunctionComponent<ButtonLineProps> = (props) => { | ||
const classes = useButtonLineStyles(); | ||
export const ButtonLine: FunctionComponent<ButtonProps> = (props) => { | ||
return ( | ||
<LineContainer> | ||
<Button className={classes.button} {...props}> | ||
<Body1>{props.label}</Body1> | ||
</Button> | ||
<Button {...props} /> | ||
</LineContainer> | ||
); | ||
}; | ||
|
||
export const Button: FunctionComponent<ButtonProps> = (props) => { | ||
const classes = useButtonLineStyles(); | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const { icon: Icon, ...buttonProps } = props; | ||
|
||
return ( | ||
<FluentButton iconPosition="after" className={classes.button} {...buttonProps} icon={Icon && <Icon />}> | ||
<Body1>{props.label}</Body1> | ||
</FluentButton> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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
54 changes: 54 additions & 0 deletions
54
packages/dev/sharedUiComponents/src/fluent/primitives/draggable.tsx
This file contains hidden or 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,54 @@ | ||
import { makeStyles, tokens } from "@fluentui/react-components"; | ||
import { DeleteFilled } from "@fluentui/react-icons"; | ||
import { LineContainer } from "../hoc/propertyLine"; | ||
|
||
export type DraggableLineProps = { | ||
format: string; | ||
data: string; | ||
tooltip: string; | ||
label: string; | ||
onDelete?: () => void; | ||
}; | ||
|
||
const useDraggableStyles = makeStyles({ | ||
draggable: { | ||
display: "inline-flex", | ||
alignItems: "center", | ||
columnGap: tokens.spacingHorizontalS, | ||
cursor: "grab", | ||
textAlign: "center", | ||
boxSizing: "border-box", | ||
borderBottom: "black", | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
margin: `${tokens.spacingVerticalXS} 0px`, | ||
border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke1}`, | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
":hover": { | ||
backgroundColor: tokens.colorBrandBackground2Hover, | ||
}, | ||
}, | ||
icon: { | ||
pointerEvents: "auto", // re‑enable interaction | ||
display: "flex", | ||
alignItems: "center", | ||
}, | ||
}); | ||
|
||
export const DraggableLine: React.FunctionComponent<DraggableLineProps> = (props) => { | ||
const classes = useDraggableStyles(); | ||
return ( | ||
<div | ||
className={classes.draggable} | ||
title={props.tooltip} | ||
draggable={true} | ||
onDragStart={(event) => { | ||
event.dataTransfer.setData(props.format, props.data); | ||
}} | ||
> | ||
<LineContainer> | ||
{props.label} | ||
{props.onDelete && <DeleteFilled className={classes.icon} onClick={props.onDelete} />} | ||
</LineContainer> | ||
</div> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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
45 changes: 23 additions & 22 deletions
45
packages/dev/sharedUiComponents/src/lines/draggableLineComponent.tsx
This file contains hidden or 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,28 +1,29 @@ | ||
import * as React from "react"; | ||
import { useContext } from "react"; | ||
import { ToolContext } from "shared-ui-components/fluent/hoc/fluentToolWrapper"; | ||
import { DraggableLine } from "shared-ui-components/fluent/primitives/draggable"; | ||
|
||
export interface IButtonLineComponentProps { | ||
export type DraggableLineProps = { | ||
format: string; | ||
data: string; | ||
tooltip: string; | ||
} | ||
}; | ||
|
||
export class DraggableLineComponent extends React.Component<IButtonLineComponentProps> { | ||
constructor(props: IButtonLineComponentProps) { | ||
super(props); | ||
export const DraggableLineComponent: React.FunctionComponent<DraggableLineProps> = (props) => { | ||
const useFluent = useContext(ToolContext); | ||
if (useFluent) { | ||
// When updating the callsites to use fluent directly this label will be clearer since the string replace occurs where the Block_Foo lives | ||
return <DraggableLine {...props} label={props.data.replace("Block", "")} />; | ||
} | ||
|
||
override render() { | ||
return ( | ||
<div | ||
className="draggableLine" | ||
title={this.props.tooltip} | ||
draggable={true} | ||
onDragStart={(event) => { | ||
event.dataTransfer.setData(this.props.format, this.props.data); | ||
}} | ||
> | ||
{this.props.data.replace("Block", "")} | ||
</div> | ||
); | ||
} | ||
} | ||
return ( | ||
<div | ||
className="draggableLine" | ||
title={props.tooltip} | ||
draggable={true} | ||
onDragStart={(event) => { | ||
event.dataTransfer.setData(props.format, props.data); | ||
}} | ||
> | ||
{props.data.replace("Block", "")} | ||
</div> | ||
); | ||
}; |
55 changes: 28 additions & 27 deletions
55
packages/dev/sharedUiComponents/src/lines/draggableLineWithButtonComponent.tsx
This file contains hidden or 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,41 +1,42 @@ | ||
import * as React from "react"; | ||
import { useContext } from "react"; | ||
import { ToolContext } from "../fluent/hoc/fluentToolWrapper"; | ||
import { DraggableLine } from "../fluent/primitives/draggable"; | ||
|
||
export interface IDraggableLineWithButtonComponent { | ||
export type DraggableLineProps = { | ||
format: string; | ||
data: string; | ||
tooltip: string; | ||
iconImage: any; | ||
onIconClick: (value: string) => void; | ||
iconTitle: string; | ||
lenSuffixToRemove?: number; | ||
} | ||
}; | ||
|
||
export class DraggableLineWithButtonComponent extends React.Component<IDraggableLineWithButtonComponent> { | ||
constructor(props: IDraggableLineWithButtonComponent) { | ||
super(props); | ||
export const DraggableLineWithButtonComponent: React.FunctionComponent<DraggableLineProps> = (props) => { | ||
const useFluent = useContext(ToolContext); | ||
if (useFluent) { | ||
// When updating the callsites to use fluent directly this label will be clearer since the string replace occurs where the data string lives | ||
return <DraggableLine {...props} label={props.data.substring(0, props.data.length - (props.lenSuffixToRemove ?? 6))} onDelete={() => props.onIconClick(props.data)} />; | ||
} | ||
|
||
override render() { | ||
return ( | ||
return ( | ||
<div | ||
className="draggableLine withButton" | ||
title={props.tooltip} | ||
draggable={true} | ||
onDragStart={(event) => { | ||
event.dataTransfer.setData(props.format, props.data); | ||
}} | ||
> | ||
{props.data.substring(0, props.data.length - (props.lenSuffixToRemove ?? 6))} | ||
<div | ||
className="draggableLine withButton" | ||
title={this.props.tooltip} | ||
draggable={true} | ||
onDragStart={(event) => { | ||
event.dataTransfer.setData(this.props.format, this.props.data); | ||
className="icon" | ||
onClick={() => { | ||
props.onIconClick(props.data); | ||
}} | ||
title={props.iconTitle} | ||
> | ||
{this.props.data.substring(0, this.props.data.length - (this.props.lenSuffixToRemove ?? 6))} | ||
<div | ||
className="icon" | ||
onClick={() => { | ||
this.props.onIconClick(this.props.data); | ||
}} | ||
title={this.props.iconTitle} | ||
> | ||
<img className="img" title={this.props.iconTitle} src={this.props.iconImage} /> | ||
</div> | ||
<img className="img" title={props.iconTitle} src={props.iconImage} /> | ||
</div> | ||
); | ||
} | ||
} | ||
</div> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.