diff --git a/src/components/InlineEditInput.res b/src/components/InlineEditInput.res index a46b0c0c0..ec0a3b30d 100644 --- a/src/components/InlineEditInput.res +++ b/src/components/InlineEditInput.res @@ -1,14 +1,6 @@ module HoverInline = { @react.component - let make = ( - ~customStyle="", - ~leftIcon, - ~value, - ~showSubText, - ~subText, - ~onHoverEdit, - ~leftActionButtons, - ) => { + let make = (~customStyle="", ~leftIcon, ~value, ~subText, ~onHoverEdit, ~leftActionButtons) => {
@@ -17,7 +9,7 @@ module HoverInline = {

{React.string(value)}

- + LogicUtils.isNonEmptyString}> {subText->React.string}
@@ -35,7 +27,6 @@ module HoverInline = { let make = ( ~index=0, ~labelText="", - ~showSubText=false, ~subText="", ~customStyle="", ~onHoverEdit=true, @@ -47,6 +38,7 @@ let make = ( ~showEditIcon=true, ~handleEdit: option => unit>=?, ~currentlyEditingId=None, + ~closeOnOutsideClick=true, ) => { let (isEditingInLine, setIsEditing) = React.useState(_ => currentlyEditingId->Option.isSome) let (value, setValue) = React.useState(_ => labelText) @@ -59,12 +51,19 @@ let make = ( | None => () } switch handleEdit { - | Some(func) => func(Some(index)) + | Some(func) => func(None) | None => () } setIsEditing(_ => false) } + React.useEffect(() => { + if labelText->String.length > 0 { + setValue(_ => labelText) + } + None + }, [labelText]) + let handleCancel = () => { setValue(_ => labelText) setIsEditing(_ => false) @@ -116,7 +115,9 @@ let make = ( Option.isSome}> - {customIconComponent->Option.getOr(React.null)} +
+ {customIconComponent->Option.getOr(React.null)} +
@@ -133,8 +134,8 @@ let make = ( }}> {if isEditingInLine {
-
+ className={`group relative flex items-center bg-white focus-within:ring-1 focus-within:ring-primary rounded-md text-md ${customStyle}`}> +
} else { Option.isNone}> - + }}
diff --git a/src/screens/Sidebar/OrgSidebar.res b/src/screens/Sidebar/OrgSidebar.res index 77478ff97..2c182680f 100644 --- a/src/screens/Sidebar/OrgSidebar.res +++ b/src/screens/Sidebar/OrgSidebar.res @@ -4,16 +4,11 @@ module OrgTile = { ~orgID: string, ~isActive, ~orgSwitch, - ~onEdit, ~orgName: string, ~index: int, ~currentlyEditingId: option, ~handleIdUnderEdit, ) => { - let { - globalUIConfig: {sidebarColor: {backgroundColor, secondaryTextColor, hoverColor}}, - } = React.useContext(ThemeProvider.themeContext) - let (orgList, _) = Recoil.useRecoilState(HyperswitchAtom.orgListAtom) let { globalUIConfig: {sidebarColor: {backgroundColor, primaryTextColor, secondaryTextColor}}, @@ -36,29 +31,38 @@ module OrgTile = { let hoverLable1 = currentlyEditingId->Option.isSome ? `` : `group/parent` let hoverInput2 = currentlyEditingId->Option.isSome ? `` : `opacity-0 group-hover/parent:opacity-100` - + let wrapperCss = switch (currentlyEditingId, isActive) { + | (Some(_), true) => + `absolute left-full top-0 z-50 ${backgroundColor.sidebarSecondary} p-2 rounded-md` + | (None, _) => + `absolute ${backgroundColor.sidebarSecondary} border border-transparent left-full top-0 rounded-md ${hoverInput2} shadow-lg z-50 p-2 hello` + | (Some(_), false) => "" + }
- {displayText->React.string} + onClick={_ => orgSwitch(orgID)->ignore} + className={`w-10 h-10 flex items-center justify-center relative cursor-pointer ${hoverLable1} `}>
- } - showEditIcon=isActive - handleEdit=handleIdUnderEdit - currentlyEditingId - /> + className={`w-8 h-8 border cursor-pointer flex items-center justify-center rounded-md shadow-md ${isActive + ? `bg-white/20 ${primaryTextColor} border-sidebar-secondaryTextColor` + : ` ${secondaryTextColor} hover:bg-white/10 border-sidebar-secondaryTextColor/30`}`}> + {displayText->React.string} +
+ } + showEditIcon=isActive + handleEdit=handleIdUnderEdit + currentlyEditingId + closeOnOutsideClick=true + /> +
} @@ -75,7 +79,6 @@ module EditState = { { None }, []) - let onEditClick = e => { - setShowEditOrgModal(_ => true) - e->ReactEvent.Mouse.stopPropagation - } - let orgSwitch = async value => { try { setShowSwitchingOrg(_ => true) @@ -277,12 +275,12 @@ let make = () => { } let (currentlyEditingId, setUnderEdit) = React.useState(_ => None) let handleIdUnderEdit = (selectedEditId: option) => { - Js.log2(selectedEditId, "LOG LOG") setUnderEdit(_ => selectedEditId) } +
// the org tiles -
+
{orgList ->Array.toSorted((org1, org2) => { if org1.id === orgId { @@ -298,7 +296,6 @@ let make = () => { orgID={org.id} isActive={org.id === orgId} orgSwitch - onEdit=onEditClick orgName={org.name} index={i} handleIdUnderEdit