From 885613d5cbcb5492834f55e24caa192019388012 Mon Sep 17 00:00:00 2001 From: terynkum Date: Fri, 14 Feb 2025 12:38:59 -0800 Subject: [PATCH] refactored code to improve usability and readability --- .../src/components/Demo/Demo.tsx | 142 ++++++++++----- .../src/components/Export/ExportPanel.tsx | 166 ++++++++++-------- .../src/components/Sidebar/Form.tsx | 16 -- 3 files changed, 184 insertions(+), 140 deletions(-) diff --git a/packages/react-components/theme-designer/src/components/Demo/Demo.tsx b/packages/react-components/theme-designer/src/components/Demo/Demo.tsx index ef485f4c161475..61ca57cccdeb68 100644 --- a/packages/react-components/theme-designer/src/components/Demo/Demo.tsx +++ b/packages/react-components/theme-designer/src/components/Demo/Demo.tsx @@ -90,34 +90,101 @@ const useStyles = makeStyles({ 3) Note that the spinner was removed since it was causing confusing with the loading state of the page */ -export const Column1 = () => { +const AvatarSection = () => { const styles = useStyles(); - const dropdownId = useId('dropdown-default'); return ( -
-
- -
+
+ +
+ ); +}; + +const TabSection = () => { + const tabValues = ['Home', 'Pages', 'Documents']; + return ( - Home - Pages - Documents + {tabValues.map((tab, index) => ( + {tab} + ))} - - } size="small" />} - /> + ); +}; + +const InputSection = () => { + const dropdownId = useId('dropdown-default'); + const optionValues = ['Option 1', 'Option 2', 'Option 3']; + return ( + <> + + } size="small" />} + /> + + + {optionValues.map((option, index) => ( + + ))} + + + ) +}; + +const ControlRow = () => { + const styles = useStyles(); + return ( +
+ +
+ + +
+
+ ); +}; + +const CheckboxSection = () => { + const styles = useStyles(); + return ( +
+
+ + +
+
+ + + + +
+
+ ); +}; + +const DescriptionSection = () => { + const styles = useStyles(); + return ( +
+ + - - - - - +
+ ); +}; + +export const Column1 = () => { + const styles = useStyles(); + return ( +
+ + +
); }; @@ -126,26 +193,9 @@ export const Column2 = () => { const styles = useStyles(); return (
-
- -
- - -
-
+ -
-
- - -
-
- - - - -
-
+
); }; @@ -170,12 +220,8 @@ export const Column3 = () => { return (
-
- - - -
- Example link - www.microsoft.com + + Example link - www.microsoft.com
); }; diff --git a/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx b/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx index 4cf65bc0bdc2dc..a6ff9d63aa03c5 100644 --- a/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx +++ b/packages/react-components/theme-designer/src/components/Export/ExportPanel.tsx @@ -46,26 +46,85 @@ const useStyles = makeStyles({ height: '100%', boxSizing: 'border-box', }, + panelContainer: { + zIndex: 100, + position: 'absolute', + top: '0px', + right: '0px', + width: '400px', + border: `1px solid ${tokens.colorNeutralStroke1}`, + borderRadius: tokens.borderRadiusXLarge, + backgroundColor: tokens.colorNeutralBackground1, + boxShadow: tokens.shadow64, + padding: '16px', + } }); +const ExportPanelHeader = ({ onClose }: { onClose: () => void }) => { + const styles = useStyles(); + return ( +
+ + Export Theme + +
+ ); +}; + +const ExportPanelContent = ({ + selectedValue, + onTabSelect, + exportedValue, + onClickCopyToClipboard, +}: { + selectedValue: TabValue; + onTabSelect: (event: SelectTabEvent, data: SelectTabData) => void; + exportedValue: string; + onClickCopyToClipboard: () => void; +}) => { + const styles = useStyles(); + return ( + <> + + Passing this theme to a FluentProvider will automatically apply it to any Fluent components below it. You can + also export this to CodeSandbox with a few component examples below. + +
+ + Code + JSON (light) + JSON (dark) + +