Skip to content

Commit

Permalink
[components, form-builder] fix asset menu styling (#2082)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicmeow committed Oct 21, 2020
1 parent 6029ef1 commit f59ad6c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
4 changes: 4 additions & 0 deletions packages/@sanity/components/src/buttons/DropDownButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
display: flex;
align-items: center;
padding: calc(var(--medium-padding) - var(--extra-small-padding)) var(--medium-padding);

@nest &[data-color='danger'] {
color: var(--state-danger-color);
}
}

.menuItem__iconContainer {
Expand Down
3 changes: 2 additions & 1 deletion packages/@sanity/components/src/buttons/DropDownButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {ButtonProps} from './types'
interface DropdownItem {
title: string
icon?: React.ComponentType<Record<string, unknown>>
color?: string
}

interface DropdownButtonProps {
Expand Down Expand Up @@ -68,7 +69,7 @@ const DropdownMenuItem = forwardRef(
{renderItem ? (
renderItem(item)
) : (
<div className={styles.menuItem__inner}>
<div className={styles.menuItem__inner} data-color={item.color}>
{item.icon && (
<div className={styles.menuItem__iconContainer}>{createElement(item.icon)}</div>
)}
Expand Down
11 changes: 0 additions & 11 deletions packages/@sanity/form-builder/src/inputs/ImageInput/AssetMenu.css

This file was deleted.

15 changes: 0 additions & 15 deletions packages/@sanity/form-builder/src/inputs/ImageInput/AssetMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import DropDownButton from 'part:@sanity/components/buttons/dropdown'
import React from 'react'
import {AssetAction} from './types'

import styles from './AssetMenu.css'

const menuItems: AssetAction[] = [
{
name: 'showRefs',
Expand All @@ -21,18 +19,6 @@ const menuItems: AssetAction[] = [
}
]

function MenuItem(item: {color?: 'danger'; icon: React.ComponentType; title: string}) {
const {color, title, icon} = item
const Icon = icon

return (
<div className={color === 'danger' ? styles.menuItemDanger : styles.menuItem}>
<span>{icon && <Icon />}</span>
<span>{title}</span>
</div>
)
}

export default function AssetMenu({
isSelected,
onAction
Expand All @@ -47,7 +33,6 @@ export default function AssetMenu({
placement="bottom-end"
showArrow={false}
items={isSelected ? menuItems.filter(item => item.name !== 'delete') : menuItems}
renderItem={MenuItem}
onAction={onAction}
/>
)
Expand Down

1 comment on commit f59ad6c

@vercel
Copy link

@vercel vercel bot commented on f59ad6c Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.