-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AP-138]: Asset preview component (#50)
* Task: implement asset-preview and dropdown-menu * Task: implement asset-preview and dropdown-menu * Task: rename preview and extract menu items * Fix: merge conflicts * Fix: lint
- Loading branch information
Showing
29 changed files
with
440 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
assets/js/src/assets/icons/core/info-circle-outlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions
55
assets/js/src/components/dropdown-menu/dropdown-menu.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { type Meta } from '@storybook/react' | ||
import { DropdownMenu as DropdownMenuComponent, type DropdownMenuItemProps } from './dropdown-menu' | ||
import { Button } from 'antd' | ||
import { Icon } from '@Pimcore/components/icon/icon' | ||
import React from 'react' | ||
import i18n from '@Pimcore/app/i18n' | ||
|
||
const config: Meta = { | ||
title: 'Pimcore studio/UI/DropdownMenu', | ||
component: DropdownMenuComponent, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} | ||
|
||
export default config | ||
|
||
const children = | ||
<Button | ||
size="small" | ||
icon={<Icon name="dots-horizontal"/>} | ||
/> | ||
|
||
const dropdownItems: DropdownMenuItemProps[] = [ | ||
{ | ||
iconNameLeft: 'target', | ||
label: i18n.t('preview-card.locate-in-tree') | ||
}, | ||
{ | ||
iconNameLeft: 'info-circle-outlined', | ||
label: i18n.t('preview-card.info'), | ||
iconNameRight: 'right-outlined' | ||
}, | ||
{ | ||
iconNameLeft: 'rich-edit', | ||
label: i18n.t('preview-card.rename') | ||
}, | ||
{ | ||
iconNameLeft: 'download-02', | ||
label: i18n.t('preview-card.download-zip') | ||
}, | ||
{ | ||
iconNameLeft: 'delete-outlined', | ||
label: i18n.t('preview-card.delete') | ||
} | ||
] | ||
|
||
export const _default = { | ||
args: { | ||
children, | ||
placement: 'bottomLeft', | ||
dropdownItems | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
assets/js/src/components/dropdown-menu/dropdown-menu.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createStyles } from 'antd-style' | ||
|
||
export const useStyle = createStyles(({ token, css }) => { | ||
return { | ||
'menu-icon': css` | ||
vertical-align: middle; | ||
margin-right: ${token.marginXS}px; | ||
`, | ||
'flexbox-start-end': css` | ||
display: flex; | ||
justify-content: space-between; | ||
` | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Dropdown, type DropdownProps, type MenuProps } from 'antd' | ||
import React, { type ReactElement } from 'react' | ||
import { Icon } from '@Pimcore/components/icon/icon' | ||
import { useStyle } from './dropdown-menu.styles' | ||
|
||
export interface DropdownMenuItemProps { | ||
iconNameLeft: string | ||
label: string | ||
onClick?: () => void | ||
iconNameRight?: string | ||
} | ||
|
||
interface DropdownMenuProps extends React.PropsWithChildren { | ||
children: ReactElement | ||
placement: DropdownProps['placement'] | ||
dropdownItems: DropdownMenuItemProps[] | ||
openClassName?: string | ||
} | ||
|
||
export const DropdownMenu = ({ | ||
children, | ||
placement, | ||
dropdownItems, | ||
openClassName | ||
}: DropdownMenuProps | ||
): React.JSX.Element => { | ||
const items: MenuProps['items'] = [] | ||
|
||
dropdownItems.forEach((item, index) => { | ||
items.push( | ||
{ | ||
key: index.toString(), | ||
label: ( | ||
<MenuItemContent item={item} /> | ||
) | ||
} | ||
) | ||
}) | ||
|
||
return ( | ||
<div> | ||
<Dropdown menu={{ items }} | ||
placement={placement} | ||
openClassName={openClassName} | ||
> | ||
{children} | ||
</Dropdown> | ||
</div> | ||
) | ||
} | ||
|
||
function MenuItemContent (prop): React.JSX.Element { | ||
const { item } = prop | ||
const { styles } = useStyle() | ||
const iconOptions = { width: '16px', height: '16px' } | ||
|
||
if (item.iconNameRight as boolean) { | ||
return ( | ||
<div onClick={item.onClick} | ||
className={styles['flexbox-start-end']} | ||
> | ||
<div> | ||
<Icon name={item.iconNameLeft} options={iconOptions} className={styles['menu-icon']}/> | ||
{item.label} | ||
</div> | ||
<div> | ||
<Icon name={item.iconNameRight} options={iconOptions} className={styles['menu-icon']}/> | ||
</div> | ||
</div> | ||
|
||
) | ||
} | ||
|
||
return ( | ||
<div onClick={item.onClick}> | ||
<Icon name={item.iconNameLeft} options={iconOptions} className={styles['menu-icon']} /> | ||
{item.label} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
assets/js/src/components/pimcore-image/pimcore-image.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { type Meta } from '@storybook/react' | ||
import { PimcoreImage as PimcoreImageComponent } from './pimcore-image' | ||
|
||
const config: Meta = { | ||
title: 'Pimcore studio/UI/PimcoreImage', | ||
component: PimcoreImageComponent, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} | ||
|
||
export default config | ||
|
||
export const _default = { | ||
args: { | ||
src: 'https://pimcore.com/brand/Website-Banners/image-thumb__23862__header-sujet-img__2019--slider/2024-Pimcore-Home-Main.webp', | ||
alt: 'Pimconaut', | ||
className: '' | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
assets/js/src/components/pimcore-image/pimcore-image.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createStyles } from 'antd-style' | ||
|
||
export const useStyle = createStyles(({ token, css }) => { | ||
return { | ||
'loading-div': css` | ||
position: absolute; | ||
top: calc(50% - 11px); | ||
left: calc(50% - 8px); | ||
` | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Image, type ImageProps, Spin } from 'antd' | ||
import React from 'react' | ||
import { useStyle } from '@Pimcore/components/pimcore-image/pimcore-image.styles' | ||
|
||
interface PimcoreImageProps extends ImageProps { | ||
} | ||
|
||
export const PimcoreImage = ( | ||
props: PimcoreImageProps | ||
): React.JSX.Element => { | ||
const { styles } = useStyle() | ||
|
||
return ( | ||
<Image | ||
placeholder={ | ||
<div className={styles['loading-div']}> | ||
<Spin size="small" /> | ||
</div> | ||
} | ||
preview={false} | ||
{...props} | ||
/> | ||
) | ||
} |
48 changes: 48 additions & 0 deletions
48
assets/js/src/components/preview-card/preview-card.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { type Meta } from '@storybook/react' | ||
import { PreviewCard as PreviewCardComponent } from './preview-card' | ||
import { type DropdownMenuItemProps } from '@Pimcore/components/dropdown-menu/dropdown-menu' | ||
import i18n from '@Pimcore/app/i18n' | ||
|
||
const config: Meta = { | ||
title: 'Pimcore studio/UI/PreviewCard', | ||
component: PreviewCardComponent, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
tags: ['autodocs'] | ||
} | ||
|
||
export default config | ||
|
||
const dropdownItems: DropdownMenuItemProps[] = [ | ||
{ | ||
iconNameLeft: 'target', | ||
label: i18n.t('preview-card.locate-in-tree') | ||
}, | ||
{ | ||
iconNameLeft: 'info-circle-outlined', | ||
label: i18n.t('preview-card.info'), | ||
iconNameRight: 'right-outlined' | ||
}, | ||
{ | ||
iconNameLeft: 'rich-edit', | ||
label: i18n.t('preview-card.rename') | ||
}, | ||
{ | ||
iconNameLeft: 'download-02', | ||
label: i18n.t('preview-card.download-zip') | ||
}, | ||
{ | ||
iconNameLeft: 'delete-outlined', | ||
label: i18n.t('preview-card.delete') | ||
} | ||
] | ||
|
||
export const _default = { | ||
args: { | ||
name: 'Pimconaout0_123.jpg', | ||
selected: false, | ||
imgSrc: 'https://pimcore.com/brand/Website-Banners/image-thumb__23862__header-sujet-img__2019--slider/2024-Pimcore-Home-Main.webp', | ||
dropdownItems | ||
} | ||
} |
Oops, something went wrong.