Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(releases): UI for hiding prespective layers #7678

Merged
merged 11 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {EyeOpenIcon} from '@sanity/icons'
// eslint-disable-next-line no-restricted-imports -- custom use for MenuItem not supported by ui-components
import {Box, Flex, MenuItem, Stack, Text} from '@sanity/ui'
// eslint-disable-next-line no-restricted-imports -- custom use for MenuItem & Button not supported by ui-components
import {Box, Button, 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 {usePerspective} from '../hooks/usePerspective'
import {GlobalPerspectiveMenuItemIndicator} from './PerspectiveLayerIndicator'
Expand All @@ -17,6 +18,25 @@ export interface LayerRange {
}
}

const ToggleLayerButton = styled(Button)`
--card-fg-color: inherit;
--card-icon-color: inherit;
background-color: inherit;
opacity: 1;
@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 +126,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>
</>
)
}
Loading