diff --git a/src/Toolbar.module.css b/src/Toolbar.module.css index 3d1a41cfb..d807a6831 100644 --- a/src/Toolbar.module.css +++ b/src/Toolbar.module.css @@ -47,15 +47,52 @@ @apply hover:bg-cool-20; } -.smallScrollbar::-webkit-scrollbar { +.toolbarButtons::-webkit-scrollbar { @apply h-0.5; } -.smallScrollbar { - @apply overflow-x-auto; +.toolbarButtons { + @apply flex items-center overflow-x-auto; scrollbar-width: thin; } +.toolbarButtons button { + @apply text-chalkboard-90 bg-chalkboard-10/50 border-chalkboard-50 whitespace-nowrap; + display: inline-flex; + align-items: center; + justify-content: center; + @apply gap-1.5 p-0.5 pr-1; + @apply rounded-sm; +} +:global(.dark) .toolbarButtons button { + @apply text-chalkboard-30 bg-chalkboard-90/50 border-chalkboard-50; +} +.toolbarButtons button:hover { + @apply text-cool-90 bg-cool-10; +} +:global(.sketch) .toolbarButtons button:hover { + @apply text-fern-90 bg-fern-10; +} +.toolbarButtons button:disabled { + @apply text-chalkboard-70 bg-chalkboard-30; +} +.toolbarButtons button:disabled:hover { + @apply !bg-inherit !text-inherit cursor-not-allowed; +} + +:global(.dark) .toolbarButtons button { + @apply text-chalkboard-20 border-chalkboard-50; +} +:global(.dark) .toolbarButtons button:hover { + @apply text-cool-10 border-chalkboard-50 bg-cool-90; +} +:global(.dark .sketch) .toolbarButtons button:hover { + @apply text-fern-10 border-chalkboard-50 bg-fern-90; +} +:global(.dark) .toolbarButtons button:disabled { + @apply text-chalkboard-40 bg-chalkboard-80; +} + :global(.dark) .popoverToggle { @apply hover:bg-cool-90; } diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 91bf46a93..0e1846334 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -1,4 +1,4 @@ -import { useStore, toolTips, Selections } from './useStore' +import { useStore, toolTips, ToolTip } from './useStore' import { extrudeSketch, sketchOnExtrudedFace } from './lang/modifyAst' import { getNodePathFromSourceRange } from './lang/queryAst' import { HorzVert } from './components/Toolbar/HorzVert' @@ -17,6 +17,30 @@ import { Popover, Transition } from '@headlessui/react' import styles from './Toolbar.module.css' import { v4 as uuidv4 } from 'uuid' import { useAppMode } from 'hooks/useAppMode' +import { ActionIcon } from 'components/ActionIcon' + +export const sketchButtonClassnames = { + background: + 'bg-chalkboard-100 group-hover:bg-chalkboard-90 hover:bg-chalkboard-90 dark:bg-fern-20 dark:group-hover:bg-fern-10 dark:hover:bg-fern-10 group-disabled:bg-chalkboard-50 dark:group-disabled:bg-chalkboard-60 group-hover:group-disabled:bg-chalkboard-50 dark:group-hover:group-disabled:bg-chalkboard-50', + icon: 'text-fern-20 h-auto group-hover:text-fern-10 hover:text-fern-10 dark:text-chalkboard-100 dark:group-hover:text-chalkboard-100 dark:hover:text-chalkboard-100 group-disabled:bg-chalkboard-60 hover:group-disabled:text-inherit', +} + +const sketchFnLabels: Record = { + sketch_line: 'Line', + line: 'Line', + move: 'Move', + angledLine: 'Angled Line', + angledLineThatIntersects: 'Angled Line That Intersects', + angledLineOfXLength: 'Angled Line Of X Length', + angledLineOfYLength: 'Angled Line Of Y Length', + angledLineToX: 'Angled Line To X', + angledLineToY: 'Angled Line To Y', + lineTo: 'Line to Point', + xLine: 'Horizontal Line', + yLine: 'Vertical Line', + xLineTo: 'Horizontal Line to Point', + yLineTo: 'Vertical Line to Point', +} export const Toolbar = () => { const { @@ -44,9 +68,9 @@ export const Toolbar = () => { console.log('guiMode', guiMode) }, [guiMode]) - function ToolbarButtons() { + function ToolbarButtons({ className }: React.HTMLAttributes) { return ( - + {guiMode.mode === 'default' && ( )} @@ -74,8 +100,10 @@ export const Toolbar = () => { ) updateAst(modifiedAst, true) }} + className="group" > - SketchOnFace + + Sketch on Face )} {guiMode.mode === 'canEditSketch' && ( @@ -98,7 +126,9 @@ export const Toolbar = () => { position: guiMode.position, }) }} + className="group" > + Edit Sketch )} @@ -117,8 +147,10 @@ export const Toolbar = () => { ) updateAst(modifiedAst, true, { focusPath: pathToExtrudeArg }) }} + className="group" > - ExtrudeSketch + + Extrude )} @@ -157,7 +191,15 @@ export const Toolbar = () => { setGuiMode({ mode: 'default' }) executeAst() }} + className="group" > + Exit sketch )} @@ -201,9 +243,21 @@ export const Toolbar = () => { }), }) }} + className={ + 'group ' + + (guiMode.sketchMode === sketchFnName + ? '!text-fern-70 !bg-fern-10 !dark:text-fern-20 !border-fern-50' + : '') + } > - {sketchFnName} - {guiMode.sketchMode === sketchFnName && '✅'} + + {sketchFnLabels[sketchFnName]} ) })} @@ -234,7 +288,7 @@ export const Toolbar = () => { {guiMode.mode === 'sketch' ? '2D' : '3D'} - + {
- +
diff --git a/src/components/ActionIcon.tsx b/src/components/ActionIcon.tsx index 62d486ec5..2cded944e 100644 --- a/src/components/ActionIcon.tsx +++ b/src/components/ActionIcon.tsx @@ -4,6 +4,7 @@ import { } from '@fortawesome/free-solid-svg-icons' import { IconDefinition as BrandIconDefinition } from '@fortawesome/free-brands-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { CustomIcon, CustomIconName } from './CustomIcon' const iconSizes = { sm: 12, @@ -13,7 +14,7 @@ const iconSizes = { } export interface ActionIconProps extends React.PropsWithChildren { - icon?: SolidIconDefinition | BrandIconDefinition + icon?: SolidIconDefinition | BrandIconDefinition | CustomIconName className?: string bgClassName?: string iconClassName?: string @@ -28,25 +29,39 @@ export const ActionIcon = ({ size = 'md', children, }: ActionIconProps) => { + // By default, we reverse the icon color and background color in dark mode + const computedIconClassName = + iconClassName || + `text-liquid-20 h-auto group-hover:text-liquid-10 hover:text-liquid-10 dark:text-chalkboard-100 dark:group-hover:text-chalkboard-100 dark:hover:text-chalkboard-100 group-disabled:bg-chalkboard-50 dark:group-disabled:bg-chalkboard-60 group-hover:group-disabled:bg-chalkboard-50 dark:group-hover:group-disabled:bg-chalkboard-50` + + const computedBgClassName = + bgClassName || + `bg-chalkboard-100 group-hover:bg-chalkboard-90 hover:bg-chalkboard-90 dark:bg-liquid-20 dark:group-hover:bg-liquid-10 dark:hover:bg-liquid-10 group-disabled:bg-chalkboard-80 dark:group-disabled:bg-chalkboard-80` + return (
- {children || ( + {children ? ( + children + ) : typeof icon === 'string' ? ( + + ) : ( )}
diff --git a/src/components/AppHeader.tsx b/src/components/AppHeader.tsx index da34b920b..29980b80a 100644 --- a/src/components/AppHeader.tsx +++ b/src/components/AppHeader.tsx @@ -29,7 +29,7 @@ export const AppHeader = ({ return (
{/* Toolbar if the context deems it */} {showToolbar && ( -
+
)} diff --git a/src/components/CustomIcon.tsx b/src/components/CustomIcon.tsx new file mode 100644 index 000000000..2f572dcc9 --- /dev/null +++ b/src/components/CustomIcon.tsx @@ -0,0 +1,161 @@ +export type CustomIconName = + | 'equal' + | 'exit' + | 'extrude' + | 'horizontal' + | 'line' + | 'move' + | 'parallel' + | 'sketch' + | 'vertical' + +export const CustomIcon = ({ + name, + ...props +}: { + name: CustomIconName +} & React.SVGProps) => { + switch (name) { + case 'equal': + return ( + + + + ) + case 'exit': + return ( + + + + ) + + case 'extrude': + return ( + + + + ) + case 'horizontal': + return ( + + + + ) + case 'line': + return ( + + + + ) + case 'move': + return ( + + + + ) + case 'parallel': + return ( + + + + ) + case 'sketch': + return ( + + + + ) + case 'vertical': + return ( + + + + ) + } +} diff --git a/src/components/ProjectSidebarMenu.tsx b/src/components/ProjectSidebarMenu.tsx index abcc12844..141b1b340 100644 --- a/src/components/ProjectSidebarMenu.tsx +++ b/src/components/ProjectSidebarMenu.tsx @@ -26,7 +26,7 @@ const ProjectSidebarMenu = ({ className="h-9 w-auto" /> {project?.name ? project.name : 'KittyCAD Modeling App'} @@ -35,15 +35,15 @@ const ProjectSidebarMenu = ({ ) : ( KittyCAD App - + {isTauri() && project?.name ? project.name : 'KittyCAD Modeling App'} diff --git a/src/components/Toolbar/EqualAngle.tsx b/src/components/Toolbar/EqualAngle.tsx index 400decaae..7a4d65e60 100644 --- a/src/components/Toolbar/EqualAngle.tsx +++ b/src/components/Toolbar/EqualAngle.tsx @@ -12,6 +12,8 @@ import { getTransformInfos, } from '../../lang/std/sketchcombos' import { updateCursors } from '../../lang/util' +import { ActionIcon } from 'components/ActionIcon' +import { sketchButtonClassnames } from 'Toolbar' export const EqualAngle = () => { const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } = @@ -87,9 +89,17 @@ export const EqualAngle = () => { }) }} disabled={!enableEqual} - title="yo dawg" + title="Parallel (or equal angle)" + className="group" > - parallel + + Parallel ) } diff --git a/src/components/Toolbar/EqualLength.tsx b/src/components/Toolbar/EqualLength.tsx index 821639659..83fcf80b8 100644 --- a/src/components/Toolbar/EqualLength.tsx +++ b/src/components/Toolbar/EqualLength.tsx @@ -12,6 +12,8 @@ import { getTransformInfos, } from '../../lang/std/sketchcombos' import { updateCursors } from '../../lang/util' +import { ActionIcon } from 'components/ActionIcon' +import { sketchButtonClassnames } from 'Toolbar' export const EqualLength = () => { const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } = @@ -87,9 +89,17 @@ export const EqualLength = () => { }) }} disabled={!enableEqual} - title="yo dawg" + className="group" + title="Equal Length" > - EqualLength + + Equal Length ) } diff --git a/src/components/Toolbar/HorzVert.tsx b/src/components/Toolbar/HorzVert.tsx index 518768383..57d7a4523 100644 --- a/src/components/Toolbar/HorzVert.tsx +++ b/src/components/Toolbar/HorzVert.tsx @@ -11,6 +11,8 @@ import { transformAstSketchLines, } from '../../lang/std/sketchcombos' import { updateCursors } from '../../lang/util' +import { ActionIcon } from 'components/ActionIcon' +import { sketchButtonClassnames } from 'Toolbar' export const HorzVert = ({ horOrVert, @@ -66,9 +68,17 @@ export const HorzVert = ({ }) }} disabled={!enableHorz} - title="yo dawg" + className="group" + title={horOrVert === 'horizontal' ? 'Horizontal' : 'Vertical'} > - {horOrVert === 'horizontal' ? 'Horz' : 'Vert'} + + {horOrVert === 'horizontal' ? 'Horizontal' : 'Vertical'} ) } diff --git a/src/components/Toolbar/Intersect.tsx b/src/components/Toolbar/Intersect.tsx index bc389328b..5a019caa5 100644 --- a/src/components/Toolbar/Intersect.tsx +++ b/src/components/Toolbar/Intersect.tsx @@ -188,8 +188,9 @@ export const Intersect = () => { } }} disabled={!enable} + title="Set Perpendicular Distance" > - perpendicularDistance + Set Perpendicular Distance ) } diff --git a/src/components/Toolbar/RemoveConstrainingValues.tsx b/src/components/Toolbar/RemoveConstrainingValues.tsx index 98d4f94a5..552d0d316 100644 --- a/src/components/Toolbar/RemoveConstrainingValues.tsx +++ b/src/components/Toolbar/RemoveConstrainingValues.tsx @@ -70,9 +70,9 @@ export const RemoveConstrainingValues = () => { }) }} disabled={!enableHorz} - title="yo dawg" + title="Remove Constraining Values" > - RemoveConstrainingValues + Remove Constraining Values ) } diff --git a/src/components/Toolbar/SetAbsDistance.tsx b/src/components/Toolbar/SetAbsDistance.tsx index 2220505ba..73e33d003 100644 --- a/src/components/Toolbar/SetAbsDistance.tsx +++ b/src/components/Toolbar/SetAbsDistance.tsx @@ -22,11 +22,16 @@ import { updateCursors } from '../../lang/util' const getModalInfo = create(SetAngleLengthModal as any) -export const SetAbsDistance = ({ - buttonType, -}: { - buttonType: 'xAbs' | 'yAbs' | 'snapToYAxis' | 'snapToXAxis' -}) => { +type ButtonType = 'xAbs' | 'yAbs' | 'snapToYAxis' | 'snapToXAxis' + +const buttonLabels: Record = { + xAbs: 'Set distance from X Axis', + yAbs: 'Set distance from Y Axis', + snapToYAxis: 'Snap To Y Axis', + snapToXAxis: 'Snap To X Axis', +} + +export const SetAbsDistance = ({ buttonType }: { buttonType: ButtonType }) => { const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } = useStore((s) => ({ guiMode: s.guiMode, @@ -132,8 +137,9 @@ export const SetAbsDistance = ({ } }} disabled={!enableAngLen} + title={buttonLabels[buttonType]} > - {buttonType} + {buttonLabels[buttonType]} ) } diff --git a/src/components/Toolbar/SetAngleBetween.tsx b/src/components/Toolbar/SetAngleBetween.tsx index a46ed0f8a..05230ea03 100644 --- a/src/components/Toolbar/SetAngleBetween.tsx +++ b/src/components/Toolbar/SetAngleBetween.tsx @@ -147,8 +147,9 @@ export const SetAngleBetween = () => { } }} disabled={!enable} + title="Set Angle Between" > - angleBetween + Set Angle Between ) } diff --git a/src/components/Toolbar/SetHorzVertDistance.tsx b/src/components/Toolbar/SetHorzVertDistance.tsx index 582695ec0..928b4c4c0 100644 --- a/src/components/Toolbar/SetHorzVertDistance.tsx +++ b/src/components/Toolbar/SetHorzVertDistance.tsx @@ -21,17 +21,28 @@ import { GetInfoModal } from '../SetHorVertDistanceModal' import { createLiteral, createVariableDeclaration } from '../../lang/modifyAst' import { removeDoubleNegatives } from '../AvailableVarsHelpers' import { updateCursors } from '../../lang/util' +import { ActionIcon } from 'components/ActionIcon' +import { sketchButtonClassnames } from 'Toolbar' const getModalInfo = create(GetInfoModal as any) +type ButtonType = + | 'setHorzDistance' + | 'setVertDistance' + | 'alignEndsHorizontally' + | 'alignEndsVertically' + +const buttonLabels: Record = { + setHorzDistance: 'Set Horizontal Distance', + setVertDistance: 'Set Vertical Distance', + alignEndsHorizontally: 'Align Ends Horizontally', + alignEndsVertically: 'Align Ends Vertically', +} + export const SetHorzVertDistance = ({ buttonType, }: { - buttonType: - | 'setHorzDistance' - | 'setVertDistance' - | 'alignEndsHorizontally' - | 'alignEndsVertically' + buttonType: ButtonType }) => { const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } = useStore((s) => ({ @@ -169,8 +180,9 @@ export const SetHorzVertDistance = ({ } }} disabled={!enable} + title={buttonLabels[buttonType]} > - {buttonType} + {buttonLabels[buttonType]} ) } diff --git a/src/components/Toolbar/setAngleLength.tsx b/src/components/Toolbar/setAngleLength.tsx index 52de66d34..650617184 100644 --- a/src/components/Toolbar/setAngleLength.tsx +++ b/src/components/Toolbar/setAngleLength.tsx @@ -23,10 +23,17 @@ import { updateCursors } from '../../lang/util' const getModalInfo = create(SetAngleLengthModal as any) +type ButtonType = 'setAngle' | 'setLength' + +const buttonLabels: Record = { + setAngle: 'Set Angle', + setLength: 'Set Length', +} + export const SetAngleLength = ({ angleOrLength, }: { - angleOrLength: 'setAngle' | 'setLength' + angleOrLength: ButtonType }) => { const { guiMode, selectionRanges, ast, programMemory, updateAst, setCursor } = useStore((s) => ({ @@ -144,8 +151,9 @@ export const SetAngleLength = ({ } }} disabled={!enableAngLen} + title={buttonLabels[angleOrLength]} > - {angleOrLength} + {buttonLabels[angleOrLength]} ) } diff --git a/src/components/UserSidebarMenu.tsx b/src/components/UserSidebarMenu.tsx index 363b070a7..c1d336b87 100644 --- a/src/components/UserSidebarMenu.tsx +++ b/src/components/UserSidebarMenu.tsx @@ -38,7 +38,7 @@ const UserSidebarMenu = ({ user }: { user?: User }) => { {user?.image && !imageLoadFailed ? (