-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
221 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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 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
57 changes: 57 additions & 0 deletions
57
packages/twenty-front/src/modules/settings/hooks/useExpandedHeightAnimation.tsx
This file contains 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,57 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { isDefined } from 'twenty-ui'; | ||
|
||
const transitionValues = { | ||
transition: { | ||
opactity: { duration: 0.2 }, | ||
height: { duration: 0.4 }, | ||
}, | ||
transitionEnd: { | ||
overflow: 'visible', | ||
}, | ||
}; | ||
|
||
const commonStyles = { | ||
opacity: 0, | ||
height: 0, | ||
overflow: 'hidden', | ||
...transitionValues, | ||
}; | ||
|
||
const advancedSectionAnimationConfig = ( | ||
isExpanded: boolean, | ||
measuredHeight: number, | ||
) => ({ | ||
initial: { | ||
...commonStyles, | ||
}, | ||
animate: { | ||
opacity: 1, | ||
height: isExpanded ? measuredHeight : 0, | ||
...transitionValues, | ||
overflow: 'hidden', | ||
}, | ||
exit: { | ||
...commonStyles, | ||
}, | ||
}); | ||
|
||
export const useExpandedHeightAnimation = (isExpanded: boolean) => { | ||
const contentRef = useRef<HTMLDivElement>(null); | ||
const [measuredHeight, setMeasuredHeight] = useState(0); | ||
|
||
useEffect(() => { | ||
if (isDefined(contentRef.current)) { | ||
setMeasuredHeight(contentRef.current.scrollHeight); | ||
} | ||
}, [isExpanded]); | ||
|
||
return { | ||
contentRef, | ||
measuredHeight, | ||
motionAnimationVariants: advancedSectionAnimationConfig( | ||
isExpanded, | ||
measuredHeight, | ||
), | ||
}; | ||
}; |
This file contains 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
62 changes: 62 additions & 0 deletions
62
packages/twenty-front/src/modules/ui/navigation/link/components/AdvancedSettingsToggle.tsx
This file contains 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,62 @@ | ||
import { Toggle } from '@/ui/input/components/Toggle'; | ||
import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState'; | ||
import styled from '@emotion/styled'; | ||
import { useRecoilState } from 'recoil'; | ||
import { IconTool, MAIN_COLORS } from 'twenty-ui'; | ||
|
||
const StyledContainer = styled.div` | ||
align-items: center; | ||
display: flex; | ||
width: 100%; | ||
gap: ${({ theme }) => theme.spacing(2)}; | ||
`; | ||
|
||
const StyledText = styled.span` | ||
color: ${({ theme }) => theme.font.color.secondary}; | ||
font-size: ${({ theme }) => theme.font.size.sm}; | ||
font-weight: ${({ theme }) => theme.font.weight.medium}; | ||
padding: ${({ theme }) => theme.spacing(1)}; | ||
`; | ||
|
||
const StyledIconContainer = styled.div` | ||
border-right: 1px solid ${MAIN_COLORS.yellow}; | ||
display: flex; | ||
height: 16px; | ||
`; | ||
|
||
const StyledToggleContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
`; | ||
|
||
const StyledIconTool = styled(IconTool)` | ||
margin-right: ${({ theme }) => theme.spacing(0.5)}; | ||
`; | ||
|
||
export const AdvancedSettingsToggle = () => { | ||
const [isAdvancedModeEnabled, setIsAdvancedModeEnabled] = useRecoilState( | ||
isAdvancedModeEnabledState, | ||
); | ||
|
||
const onChange = (newValue: boolean) => { | ||
setIsAdvancedModeEnabled(newValue); | ||
}; | ||
|
||
return ( | ||
<StyledContainer> | ||
<StyledIconContainer> | ||
<StyledIconTool size={12} color={MAIN_COLORS.yellow} /> | ||
</StyledIconContainer> | ||
<StyledToggleContainer> | ||
<StyledText>Advanced</StyledText> | ||
<Toggle | ||
onChange={onChange} | ||
color={MAIN_COLORS.yellow} | ||
value={isAdvancedModeEnabled} | ||
/> | ||
</StyledToggleContainer> | ||
</StyledContainer> | ||
); | ||
}; |
This file contains 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 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 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
8 changes: 8 additions & 0 deletions
8
...ty-front/src/modules/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState.ts
This file contains 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,8 @@ | ||
import { atom } from 'recoil'; | ||
import { localStorageEffect } from '~/utils/recoil-effects'; | ||
|
||
export const isAdvancedModeEnabledState = atom<boolean>({ | ||
key: 'isAdvancedModeEnabledAtom', | ||
default: false, | ||
effects: [localStorageEffect()], | ||
}); |
Oops, something went wrong.