Skip to content

Commit

Permalink
Updates per design review
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 5, 2024
1 parent db408b0 commit 9e8099b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 35 deletions.
75 changes: 49 additions & 26 deletions packages/dataviews/src/components/dataviews-view-config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ import {
__experimentalText as Text,
privateApis as componentsPrivateApis,
BaseControl,
Icon,
} from '@wordpress/components';
import { __, _x, sprintf } from '@wordpress/i18n';
import { memo, useContext, useMemo } from '@wordpress/element';
import { chevronDown, chevronUp, cog, seen, unseen } from '@wordpress/icons';
import {
chevronDown,
chevronUp,
cog,
seen,
unseen,
lock,
} from '@wordpress/icons';
import warning from '@wordpress/warning';
import { useInstanceId } from '@wordpress/compose';

Expand Down Expand Up @@ -237,6 +245,7 @@ function FieldItem( {
isVisible,
isFirst,
isLast,
canMove = true,
onToggleVisibility,
onMoveUp,
onMoveDown,
Expand All @@ -245,6 +254,7 @@ function FieldItem( {
isVisible: boolean;
isFirst?: boolean;
isLast?: boolean;
canMove?: boolean;
onToggleVisibility?: () => void;
onMoveUp?: () => void;
onMoveDown?: () => void;
Expand All @@ -268,38 +278,54 @@ function FieldItem( {
<HStack
expanded
className={ `dataviews-field-control__field dataviews-field-control__field-${ field.id }` }
justify="flex-start"
>
<span>{ field.label }</span>
<span className="dataviews-field-control__icon">
{ ! canMove && ! field.enableHiding && (
<Icon icon={ lock } />
) }
</span>
<span className="dataviews-field-control__label">
{ field.label }
</span>
<HStack
justify="flex-end"
expanded={ false }
className="dataviews-field-control__actions"
>
{ onMoveUp && onMoveDown && isVisible && (
{ isVisible && (
<>
<Button
disabled={ isFirst }
disabled={ isFirst || ! canMove }
accessibleWhenDisabled
size="compact"
onClick={ onMoveUp }
icon={ chevronUp }
label={ sprintf(
/* translators: %s: field label */
__( 'Move %s up' ),
field.label
) }
label={
isFirst || ! canMove
? __( "This field can't be moved up" )
: sprintf(
/* translators: %s: field label */
__( 'Move %s up' ),
field.label
)
}
/>
<Button
disabled={ isLast }
disabled={ isLast || ! canMove }
accessibleWhenDisabled
size="compact"
onClick={ onMoveDown }
icon={ chevronDown }
label={ sprintf(
/* translators: %s: field label */
__( 'Move %s down' ),
field.label
) }
label={
isLast || ! canMove
? __( "This field can't be moved down" )
: sprintf(
/* translators: %s: field label */
__( 'Move %s down' ),
field.label
)
}
/>
</>
) }
Expand Down Expand Up @@ -464,7 +490,8 @@ function FieldControl() {
return (
<VStack className="dataviews-field-control" spacing={ 6 }>
<VStack className="dataviews-view-config__properties" spacing={ 0 }>
{ visibleLockedFields.length > 0 && (
{ ( visibleLockedFields.length > 0 ||
!! visibleFields?.length ) && (
<ItemGroup isBordered isSeparated>
{ visibleLockedFields.map(
( { field, isVisibleFlag } ) => {
Expand All @@ -479,14 +506,12 @@ function FieldControl() {
[ isVisibleFlag ]: false,
} );
} }
canMove={ false }
/>
);
}
) }
</ItemGroup>
) }
{ !! visibleFields?.length && (
<ItemGroup isBordered isSeparated>

{ visibleFields.map( ( field, index ) => (
<RegularFieldItem
key={ field.id }
Expand All @@ -509,9 +534,9 @@ function FieldControl() {
className="dataviews-view-config__properties"
spacing={ 0 }
>
{ hiddenLockedFields.length > 0 && (
<ItemGroup isBordered isSeparated>
{ hiddenLockedFields.map(
<ItemGroup isBordered isSeparated>
{ hiddenLockedFields.length > 0 &&
hiddenLockedFields.map(
( { field, isVisibleFlag } ) => {
return (
<FieldItem
Expand All @@ -524,13 +549,11 @@ function FieldControl() {
[ isVisibleFlag ]: true,
} );
} }
canMove={ false }
/>
);
}
) }
</ItemGroup>
) }
<ItemGroup isBordered isSeparated>
{ hiddenFields.map( ( field ) => (
<RegularFieldItem
key={ field.id }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@
}
}

.dataviews-view-config__properties > div {
&:not(:last-child) {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
&:not(:first-child) {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.dataviews-field-control__icon {
width: 24px;
}

.dataviews-field-control__label {
flex-grow: 1;
}

0 comments on commit 9e8099b

Please sign in to comment.