Skip to content

Commit

Permalink
feat(releases): UI for hiding prespective layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanl17 committed Oct 28, 2024
1 parent eb92a80 commit bd68097
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {EyeOpenIcon} from '@sanity/icons'
import {Box, Flex, MenuItem, Stack, Text} from '@sanity/ui'
import {type MouseEvent, useCallback} from 'react'
import {getReleaseTone, RelativeTime, ReleaseAvatar, type ReleaseDocument} from 'sanity'
import {styled} from 'styled-components'

import {Button} from '../../../ui-components/button'
import {usePerspective} from '../hooks/usePerspective'
import {GlobalPerspectiveMenuItemIndicator} from './PerspectiveLayerIndicator'

Expand All @@ -17,6 +19,25 @@ export interface LayerRange {
}
}

const ToggleLayerButton = styled(Button)`
--card-fg-color: inherit;
--card-icon-color: inherit;
background-color: inherit;
opacity: 0;
@media (hover: hover) {
&:not([data-disabled='true']):hover {
--card-fg-color: inherit;
--card-icon-color: inherit;
}
}
[data-ui='MenuItem']:hover & {
opacity: 1;
}
`

type rangePosition = 'first' | 'within' | 'last' | undefined

export function getRangePosition(range: LayerRange, index: number): rangePosition {
Expand Down Expand Up @@ -106,24 +127,19 @@ export function GlobalPerspectiveMenuItem(props: {
)}
</Stack>
<Box flex="none">
{!toggleable && (
<Box padding={2} style={{opacity: 0}}>
<Text size={1}>
<EyeOpenIcon />
</Text>
</Box>
)}
{/* {toggleable && (
{inRange && (
<ToggleLayerButton
$visible={!release.hidden}
tooltipProps={{placement: 'bottom', content: 'Hide release'}}
// $visible={!release.hidden}
forwardedAs="div"
disabled={!active}
icon={release.hidden ? EyeClosedIcon : EyeOpenIcon}
icon={EyeOpenIcon}
// icon={release.hidden ? EyeClosedIcon : EyeOpenIcon}
mode="bleed"
onClick={handleToggleReleaseVisibility}
padding={2}
/>
)} */}
)}
</Box>
</Flex>
</MenuItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export const GlobalPerspectiveMenuItemIndicator = styled.div<{
export const GlobalPerspectiveMenuLabelIndicator = styled(Box)<{$withinRange: boolean}>(
({$withinRange}) => css`
position: relative;
padding-left: 40px;
// 4px padding + 33px release indicator width + 4px gap
padding-left: 41px;
${$withinRange &&
css`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Label} from '@sanity/ui'
import {Flex, Label} from '@sanity/ui'
import {type ReleaseDocument, type ReleaseType, useTranslation} from 'sanity'

import {
Expand Down Expand Up @@ -42,14 +42,16 @@ export function ReleaseTypeSection({
{t(RELEASE_TYPE_LABELS[releaseType])}
</Label>
</GlobalPerspectiveMenuLabelIndicator>
{releases.map((release, index) => (
<GlobalPerspectiveMenuItem
release={release}
key={release._id}
rangePosition={getRangePosition(range, releaseTypeOffset + index)}
toggleable={releaseTypeOffset < lastIndex}
/>
))}
<Flex direction="column" gap={1}>
{releases.map((release, index) => (
<GlobalPerspectiveMenuItem
release={release}
key={release._id}
rangePosition={getRangePosition(range, releaseTypeOffset + index)}
toggleable={releaseTypeOffset < lastIndex}
/>
))}
</Flex>
</>
)
}

0 comments on commit bd68097

Please sign in to comment.