@atlaskit/editor-plugin-media
Version:
Media plugin for @atlaskit/editor-core
126 lines (121 loc) • 3.61 kB
JavaScript
import { css } from '@emotion/react';
import { DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
import * as colors from '@atlaskit/theme/colors';
import { N0, N20A, N50, N60A, N800, N90 } from '@atlaskit/theme/colors';
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
import { gridSize } from '@atlaskit/theme/constants';
// menuItemDimensions and itemSpacing are copied from
// packages/editor/editor-core/src/plugins/floating-toolbar/ui/DropdownMenu.tsx
export const menuItemDimensions = {
width: 175,
height: 32
};
// TODO: Migrate away from gridSize
// Recommendation: Replace directly with 4 due to itemSpacing being used in calculations
export const itemSpacing = gridSize() / 2;
export const contextualMenuArrow = css`
display: flex;
&::after {
content: '›';
margin-left: ${"var(--ds-space-050, 4px)"};
line-height: 20px;
color: ${`var(--ds-icon, ${N90})`};
}
`;
export const contextualMenuColorIcon = color => css`
${contextualMenuArrow}
&::before {
content: '';
display: block;
border: 1px solid ${DEFAULT_BORDER_COLOR};
border-radius: ${"var(--ds-border-radius-100, 3px)"};
width: 20px;
height: 20px;
${color && `background: ${color}`}
}
`;
export const contextualSubMenu = index => css`
border-radius: ${"var(--ds-border-radius-100, 3px)"};
background: ${"var(--ds-surface-overlay, white)"};
box-shadow: ${`var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N60A}, 0 0 1px ${N60A}`})`};
display: flex;
position: absolute;
top: ${index * (menuItemDimensions.height + itemSpacing * 2)}px;
left: ${menuItemDimensions.width}px;
padding: ${"var(--ds-space-100, 8px)"};
> div {
padding: 0;
}
`;
export const buttonStyle = selected => css`
height: 26px;
width: 26px;
padding: 0;
border-radius: 4px;
background-color: ${selected ? `var(--ds-text, ${N800})` : `var(--ds-background-neutral, ${N20A})`};
border: 1px solid ${DEFAULT_BORDER_COLOR};
cursor: pointer;
display: block;
`;
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
export const buttonWrapperStyle = css`
border: 1px solid transparent;
margin: 1px;
font-size: 0;
display: flex;
align-items: center;
padding: 1px;
border-radius: 6px;
&:focus-within,
&:focus,
&:hover {
border-color: ${N50} ;
}
`;
export const line = (size, selected) => css`
position: relative;
&:before {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
width: 12px;
height: ${size}px;
background-color: ${selected ? `var(--ds-icon-inverse, ${N0})` : "var(--ds-icon, #44546F)"};
border-radius: 90px;
transform: translate(-50%, -50%) rotate(135deg);
}
`;
const getHoverStyles = selector => `&:hover ${selector} {
background: ${`var(--ds-background-neutral-subtle-hovered, ${colors.N20A})`};
&:hover {
background: ${`var(--ds-background-neutral-hovered, ${colors.N30A})`};
}
}`;
export const toolbarButtonWrapper = ({
enabled,
isOpen
}) => css`
display: flex;
.image-border-toolbar-btn {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
padding: 0;
& > span {
margin: 0;
}
}
.image-border-toolbar-dropdown {
padding: 0;
& > span {
margin: 0;
}
width: 16px ;
border-top-left-radius: 0 ;
border-bottom-left-radius: 0 ;
margin-left: 1px;
}
${!enabled && getHoverStyles('.image-border-toolbar-btn')}
${!isOpen && !enabled && getHoverStyles('.image-border-toolbar-dropdown')}
`;