-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Introduce new fluent shared components; conditionally load them from existing shared components if useFluent context is true #16709
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
georginahalpern
merged 61 commits into
BabylonJS:master
from
georginahalpern:freshSharedComponents
Jun 17, 2025
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
618c2ac
Squashed: Add all changes from freshSharedComponents
a7f155f
fix eslint issues
623b303
PR comments
348b49b
merge
4d90b99
remove required dropdown defaultvalue and default to first if not sup…
b54b986
rename styles to classes when using makeStyles; remove the SplitPrope…
7b640de
rename obj/key to target/propertyKey; move type imports out of {}; a…
fcefc8f
delete the temp inspectorv2 folder, will update the true iv2 componen…
e61f9b7
package lock after npm install from codespace
georginahalpern db03499
revert eslint change
22a1413
Dummy commit
1b2dd1a
remove packagelock change from PR
ab37234
merge
d86b344
reset
1a8f367
missing command
RaananW 2e95cef
separate build process
RaananW d9335f7
try something
RaananW 7795dfb
revert
RaananW 141bf56
add back a single instance of fluent primitive, HOC, toolContext, and…
9e3b373
package lock
25e1c89
eslint
fb3f559
remove usage of the new components -- just create the components them…
e6e585d
fluentui to any
RaananW 86aa5c1
move the generateDeclaration changes from test branch into this branch
b7f3887
introduce fluentprovider and contextprovider
f402c13
explicit imports, shouldnt impact build but want to rule out
ece188d
remove nested contextprovider
709f52f
small fix
RaananW 5daac3f
fix regex
RaananW c555a1e
small push so raanan can test his change
45c21a8
remove changes to textinputlinecomponent
ff9fc0a
textinputlinecomponent import changes without yet using conditional f…
0f898d3
condiitonally load fluent, all relative imports
f34b501
remove import from root, cleanup react.changeHandlers
6de41da
update textarea import to include keyboard/change event
54b75c4
remove icons
5a94de8
reduce parallelization in umd and es6 build steps to see if it reduce…
53d405c
point public inspector/gui editor package.json entrypoint to minified…
cf35e8c
Merge branch 'master' of https://github.com/georginahalpern/Babylon.j…
d24c8d8
ensure proper binding in the fluent/original componenttype props. rev…
d5a697a
revert the parallelization change, back to 6
b50114d
just the package.jsona nd webpack config changes
50e8c2e
parallel 4
b03e1f5
revert back to using minified entrypoint, try 4 parallel processes
9c040e6
Merge branch 'sharedComponents1' of https://github.com/georginahalper…
04e8327
try both , treeshaking and minfiied entrypoint
da936aa
Merge branch 'master' of https://github.com/georginahalpern/Babylon.j…
a208d2a
point to max for umd builds too
2f7a3f2
add back raanan's optimization
834d53d
revert webpack usedexports change
7948373
Build libs (no fluent dependency) and tools (fluent dependency) separ…
ryantrem 1ebfd1d
Dummy commit
ryantrem 8037605
Merge master
ryantrem 67f851d
merge
742c957
conditionallyusefluent component
d64c0c7
merge
c4c8723
Merge branch 'master' of https://github.com/georginahalpern/Babylon.j…
6ea17ab
merge build changes from master
c6f8a00
rm webpack config change leftover from testing treeshaking
117f18f
check for existence of QSP instead of truthiness
5d6a54a
remove HOC for conditionally loading fluent
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
40 changes: 40 additions & 0 deletions
40
packages/dev/sharedUiComponents/src/fluent/hoc/colorPropertyLine.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,40 @@ | ||
| import type { FunctionComponent } from "react"; | ||
|
|
||
| import type { PropertyLineProps } from "./propertyLine"; | ||
| import { PropertyLine } from "./propertyLine"; | ||
| import { SyncedSliderLine } from "./syncedSliderLine"; | ||
|
|
||
| import type { Color3 } from "core/Maths/math.color"; | ||
| import { Color4 } from "core/Maths/math.color"; | ||
|
|
||
| type ColorSliderProps = { | ||
| color: Color3 | Color4; | ||
| }; | ||
|
|
||
| const ColorSliders: FunctionComponent<ColorSliderProps> = (props) => { | ||
| return ( | ||
| <> | ||
| <SyncedSliderLine label="R" propertyKey="r" target={props.color} min={0} max={255} /> | ||
| <SyncedSliderLine label="G" propertyKey="g" target={props.color} min={0} max={255} /> | ||
| <SyncedSliderLine label="B" propertyKey="b" target={props.color} min={0} max={255} /> | ||
| {props.color instanceof Color4 && <SyncedSliderLine label="A" propertyKey="a" target={props.color} min={0} max={1} />} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Reusable component which renders a color property line containing a label, colorPicker popout, and expandable RGBA values | ||
| * The expandable RGBA values are synced sliders that allow the user to modify the color's RGBA values directly | ||
| * @param props - PropertyLine props, replacing children with a color object so that we can properly display the color | ||
| * @returns Component wrapping a colorPicker component (coming soon) with a property line | ||
| */ | ||
| export const ColorPropertyLine: FunctionComponent<ColorSliderProps & PropertyLineProps> = (props) => { | ||
| return ( | ||
| <PropertyLine {...props} expandedContent={<ColorSliders {...props} />}> | ||
| { | ||
| props.color.toString() | ||
| // Will replace with colorPicker in future PR | ||
| } | ||
| </PropertyLine> | ||
| ); | ||
| }; |
32 changes: 32 additions & 0 deletions
32
packages/dev/sharedUiComponents/src/fluent/hoc/fluentToolWrapper.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,32 @@ | ||
| import type { PropsWithChildren, FunctionComponent } from "react"; | ||
| import { createContext } from "react"; | ||
| import type { Theme } from "@fluentui/react-components"; | ||
| import { FluentProvider, webDarkTheme } from "@fluentui/react-components"; | ||
|
|
||
| export type ToolHostProps = { | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Allows host to pass in a theme | ||
| */ | ||
| customTheme?: Theme; | ||
| }; | ||
|
|
||
| export const ToolContext = createContext({ useFluent: false as boolean } as const); | ||
|
|
||
| /** | ||
| * For tools which are ready to move over the fluent, wrap the root of the tool (or the panel which you want fluentized) with this component | ||
| * Today we will only enable fluent if the URL has the `newUX` query parameter is truthy | ||
| * @param props | ||
| * @returns | ||
| */ | ||
| export const FluentToolWrapper: FunctionComponent<PropsWithChildren<ToolHostProps>> = (props) => { | ||
| const url = new URL(window.location.href); | ||
| const enableFluent = url.searchParams.has("newUX") || url.hash.includes("newUX"); | ||
|
|
||
| return enableFluent ? ( | ||
| <FluentProvider theme={props.customTheme || webDarkTheme}> | ||
| <ToolContext.Provider value={{ useFluent: true }}>{props.children}</ToolContext.Provider> | ||
| </FluentProvider> | ||
| ) : ( | ||
| props.children | ||
| ); | ||
| }; | ||
108 changes: 108 additions & 0 deletions
108
packages/dev/sharedUiComponents/src/fluent/hoc/propertyLine.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,108 @@ | ||
| import { Body1Strong, Button, InfoLabel, makeStyles, tokens } from "@fluentui/react-components"; | ||
| import { Add24Filled, Copy24Regular, Subtract24Filled } from "@fluentui/react-icons"; | ||
| import type { FunctionComponent, PropsWithChildren } from "react"; | ||
| import { useState } from "react"; | ||
| import { copyCommandToClipboard } from "../../copyCommandToClipboard"; | ||
|
|
||
| const usePropertyLineStyles = makeStyles({ | ||
| container: { | ||
| width: "100%", | ||
| display: "flex", | ||
| flexDirection: "column", // Stack line + expanded content | ||
| borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke1}`, | ||
| }, | ||
| line: { | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "flex-start", | ||
| padding: `${tokens.spacingVerticalXS} 0px`, | ||
| width: "100%", | ||
| }, | ||
| label: { | ||
| width: "33%", | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| textAlign: "left", | ||
| }, | ||
| rightContent: { | ||
| width: "67%", | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "flex-end", | ||
| }, | ||
| button: { | ||
| marginLeft: tokens.spacingHorizontalXXS, | ||
| width: "100px", | ||
| }, | ||
| fillRestOfRightContentWidth: { | ||
| flex: 1, | ||
| display: "flex", | ||
| justifyContent: "flex-end", | ||
| alignItems: "center", | ||
| }, | ||
| expandedContent: { | ||
| backgroundColor: tokens.colorNeutralBackground1, | ||
| }, | ||
| }); | ||
|
|
||
| export type PropertyLineProps = { | ||
| /** | ||
| * The name of the property to display in the property line. | ||
| */ | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| label: string; | ||
| /** | ||
| * Optional description for the property, shown on hover of the info icon | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * Optional function returning a string to copy to clipboard. | ||
| */ | ||
| onCopy?: () => string; | ||
| /** | ||
| * If supplied, an 'expand' icon will be shown which, when clicked, renders this component within the property line. | ||
| */ | ||
| expandedContent?: JSX.Element; | ||
| }; | ||
|
|
||
| /** | ||
| * A reusable component that renders a property line with a label and child content, and an optional description, copy button, and expandable section. | ||
| * | ||
| * @param props - The properties for the PropertyLine component. | ||
| * @returns A React element representing the property line. | ||
| * | ||
| */ | ||
| export const PropertyLine: FunctionComponent<PropsWithChildren<PropertyLineProps>> = (props) => { | ||
| const classes = usePropertyLineStyles(); | ||
| const [expanded, setExpanded] = useState(false); | ||
|
|
||
| const { label, description, onCopy, expandedContent, children } = props; | ||
|
|
||
| return ( | ||
| <div className={classes.container}> | ||
| <div className={classes.line}> | ||
| <InfoLabel className={classes.label} info={description}> | ||
| <Body1Strong>{label}</Body1Strong> | ||
| </InfoLabel> | ||
| <div className={classes.rightContent}> | ||
| <div className={classes.fillRestOfRightContentWidth}>{children}</div> | ||
|
|
||
| {expandedContent && ( | ||
| <Button | ||
| appearance="subtle" | ||
| icon={expanded ? <Subtract24Filled /> : <Add24Filled />} | ||
| className={classes.button} | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| setExpanded((expanded) => !expanded); | ||
| }} | ||
| /> | ||
| )} | ||
|
|
||
| {onCopy && ( | ||
| <Button className={classes.button} id="copyProperty" icon={<Copy24Regular />} onClick={() => copyCommandToClipboard(onCopy())} title="Copy to clipboard" /> | ||
| )} | ||
| </div> | ||
| </div> | ||
|
|
||
| {expanded && expandedContent && <div className={classes.expandedContent}>{expandedContent}</div>} | ||
| </div> | ||
| ); | ||
| }; | ||
45 changes: 45 additions & 0 deletions
45
packages/dev/sharedUiComponents/src/fluent/hoc/syncedSliderLine.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,45 @@ | ||
| import { PropertyLine } from "./propertyLine"; | ||
| import type { PropertyLineProps } from "./propertyLine"; | ||
| import { SyncedSliderInput } from "../primitives/syncedSlider"; | ||
| import type { SyncedSliderProps } from "../primitives/syncedSlider"; | ||
|
|
||
| export type SyncedSliderLineProps<O, K> = PropertyLineProps & | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Omit<SyncedSliderProps, "value" | "onChange"> & { | ||
| /** | ||
| * String key | ||
| */ | ||
| propertyKey: K; | ||
| /** | ||
| * target where O[K] is a number | ||
| */ | ||
| target: O; | ||
| /** | ||
| * Callback when either the slider or input value changes | ||
| */ | ||
| onChange?: (value: number) => void; | ||
| }; | ||
|
|
||
| /** | ||
| * Renders a SyncedSlider within a PropertyLine for a given key/value pair, where the value is number (ex: can be used for a color's RGBA values, a vector's XYZ values, etc) | ||
| * When value changes, updates the object with the new value and calls the onChange callback. | ||
| * | ||
| * Example usage looks like | ||
| * \<SyncedSliderLine propertyKey="x" target=\{vector\} /\> | ||
| * \<SyncedSliderLine propertyKey="r" target=\{color\} /\> | ||
| * @param props | ||
| * @returns | ||
| */ | ||
| export const SyncedSliderLine = <O extends Record<K, number>, K extends PropertyKey>(props: SyncedSliderLineProps<O, K>): React.ReactElement => { | ||
| return ( | ||
| <PropertyLine {...props}> | ||
| <SyncedSliderInput | ||
| {...props} | ||
| value={props.target[props.propertyKey]} | ||
| onChange={(val) => { | ||
| props.target[props.propertyKey] = val as O[K]; | ||
| props.onChange?.(val); | ||
| }} | ||
| /> | ||
| </PropertyLine> | ||
| ); | ||
| }; | ||
43 changes: 43 additions & 0 deletions
43
packages/dev/sharedUiComponents/src/fluent/hoc/vectorPropertyLine.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,43 @@ | ||
| import type { FunctionComponent } from "react"; | ||
|
|
||
| import { Body1 } from "@fluentui/react-components"; | ||
| import { PropertyLine } from "./propertyLine"; | ||
| import type { PropertyLineProps } from "./propertyLine"; | ||
|
|
||
| import { SyncedSliderLine } from "./syncedSliderLine"; | ||
|
|
||
| import { Vector4 } from "core/Maths/math.vector"; | ||
| import type { Vector3 } from "core/Maths/math.vector"; | ||
|
|
||
| type VectorSliderProps = { | ||
| vector: Vector3 | Vector4; | ||
| min?: number; | ||
| max?: number; | ||
| step?: number; | ||
| }; | ||
|
|
||
| const VectorSliders: FunctionComponent<VectorSliderProps> = (props) => { | ||
| const { vector, ...sliderProps } = props; | ||
| return ( | ||
| <> | ||
| <SyncedSliderLine label="X" propertyKey="x" target={vector} {...sliderProps} /> | ||
| <SyncedSliderLine label="Y" propertyKey="y" target={vector} {...sliderProps} /> | ||
| <SyncedSliderLine label="Z" propertyKey="z" target={vector} {...sliderProps} /> | ||
| {vector instanceof Vector4 && <SyncedSliderLine label="W" propertyKey="w" target={vector} {...sliderProps} />} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Reusable component which renders a vector property line containing a label, vector value, and expandable XYZW values | ||
| * The expanded section contains a slider/input box for each component of the vector (x, y, z, w) | ||
| * @param props | ||
| * @returns | ||
| */ | ||
georginahalpern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export const VectorPropertyLine: FunctionComponent<VectorSliderProps & PropertyLineProps> = (props) => { | ||
| return ( | ||
| <PropertyLine {...props} expandedContent={<VectorSliders {...props} />}> | ||
| <Body1>{props.vector.toString()}</Body1> | ||
| </PropertyLine> | ||
| ); | ||
| }; | ||
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.