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

Add Toolbar #43

Merged
merged 36 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a6087de
added basic toolbar component
Corepex Feb 15, 2024
f39e8c3
Merge branch '1.x' into toolbar
Corepex Feb 16, 2024
e0993e7
resolved some merge issues
Corepex Feb 16, 2024
50cbafd
implemented asset provider
Corepex Feb 16, 2024
e7561db
adjust view icon color, code cleanup
Corepex Feb 19, 2024
ddd8ae4
Automatic frontend build
Corepex Feb 19, 2024
b39fb1c
Merge branch '1.x' into toolbar
Corepex Feb 20, 2024
10b2f8d
Automatic frontend build
Corepex Feb 20, 2024
5e6aed1
renamed icons, fixed fill issue
Corepex Feb 20, 2024
f53930f
Automatic frontend build
Corepex Feb 20, 2024
f8896ad
fixed some more icons, removed fill from css
Corepex Feb 20, 2024
92b3723
removed store, added tab-manager registry
Corepex Feb 20, 2024
e633312
Merge remote-tracking branch 'origin/toolbar' into toolbar
Corepex Feb 20, 2024
eafd728
renamed `tabManager` to more specific `editorTabManager`
Corepex Feb 21, 2024
033e96f
renamed `toolbar` to `editorTabs`
Corepex Feb 21, 2024
ba3cb29
renamed icons, removed not used icon
Corepex Feb 21, 2024
2bfd4a4
changed `toolbar` to `editorTabs` in asset view
Corepex Feb 21, 2024
42ca0c2
improved editorTab styles
Corepex Feb 21, 2024
f167d0d
did some css magic :S
Corepex Feb 21, 2024
ff1c421
Apply eslint-fixer changes
Corepex Feb 21, 2024
d32e39b
Automatic frontend build
Corepex Feb 21, 2024
096beee
Remove ssh key
herbertroth Feb 21, 2024
6f0d09c
corrected color of tabs
Corepex Feb 21, 2024
c2b1564
Merge remote-tracking branch 'origin/toolbar' into toolbar
Corepex Feb 21, 2024
9920c7e
Automatic frontend build
Corepex Feb 21, 2024
73fc704
fixed some more colors
Corepex Feb 21, 2024
94c4e8c
Merge remote-tracking branch 'origin/toolbar' into toolbar
Corepex Feb 21, 2024
443c002
Automatic frontend build
Corepex Feb 21, 2024
453b381
added `assets\/js` to ignore paths
Corepex Feb 21, 2024
8f09e75
revert quodana changes
Corepex Feb 21, 2024
b142443
Merge branch '1.x' into toolbar
Corepex Feb 22, 2024
3a39edb
added hover style
Corepex Feb 22, 2024
10a3f39
Automatic frontend build
Corepex Feb 22, 2024
edc73b8
added translations to tabs, removed margin-bottom from tabbar
Corepex Feb 23, 2024
8f797b5
added final build files
Corepex Feb 23, 2024
79c469c
Automatic frontend build
Corepex Feb 23, 2024
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
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/data-management-2.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions assets/js/src/assets/icons/core/data-sheet.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/edit.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/hierarchy.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/history-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.
5 changes: 5 additions & 0 deletions assets/js/src/assets/icons/core/image-05.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/schedule-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.
4 changes: 4 additions & 0 deletions assets/js/src/assets/icons/core/tag-two-tone.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/view-details.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/js/src/assets/icons/core/workflow.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions assets/js/src/components/editor-tabs/editor-tabs.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { EditorTabs } from '@Pimcore/components/editor-tabs/editor-tabs'
import { type Meta } from '@storybook/react'
import { PictureOutlined, TagOutlined } from '@ant-design/icons'
import { Icon } from '@Pimcore/components/icon/icon'
import React from 'react'

const config: Meta = {
title: 'Pimcore studio/UI/Editor Tabs',
component: EditorTabs,
parameters: {
layout: 'centered'
},
tags: ['autodocs']
}

export default config

export const _default = {
args: {
defaultActiveKey: '2',
showLabelIfActive: false,
items: [
{
key: '1',
label: 'Tab 1',
children: 'Tab 1',
icon: <PictureOutlined/>
},
{
key: '2',
label: 'Tab 2',
children: 'Tab 2',
icon: <Icon name={'edit'}/>
},
{
key: '3',
label: 'Tab 3',
children: 'Tab 3',
icon: <Icon name={'view-details'}/>
},
{
key: '4',
label: 'Tab 4',
children: 'Tab 4',
icon: <TagOutlined/>
}
]
}
}
89 changes: 89 additions & 0 deletions assets/js/src/components/editor-tabs/editor-tabs.styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { createStyles } from 'antd-style'

export const useStyle = createStyles(({ token, css }) => {
return {
editorTabs: css`
&.ant-tabs .ant-tabs-tab+.ant-tabs-tab {
margin-left: ${token.paddingSM}px;
margin-right: ${token.paddingSM}px;
}
&.ant-tabs .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {
color: ${token.colorPrimaryActive}
}
&.ant-tabs-top >.ant-tabs-nav {
margin-bottom: 0;
}

.ant-tabs-tab {
&:first-of-type {
margin-left: ${token.paddingSM}px;
margin-right: ${token.paddingSM}px;
}
padding: 0;

.ant-tabs-tab-btn {
display: flex;
padding-top: ${token.paddingXS}px;
padding-bottom: ${token.paddingXS}px;
justify-content: center;
align-items: center;
gap: ${token.Tabs.paddingTabs}px;

.ant-tabs-tab-icon {
height: 16px;
justify-content: center;
align-content: center;
margin-inline-end: 0;
color: ${token.Tabs.itemUnselectedIconColor};

svg {
height: 16px;
width: 16px
}
}
}

&:not(.ant-tabs-tab-active) {
.ant-tabs-tab-icon {
&:hover {
color: ${token.colorIconHover};
}
}
}

&.ant-tabs-tab-active {
.ant-tabs-tab-icon {
color: ${token.colorPrimaryActive}
}
}
}
`,

onlyActiveLabel: css`
.ant-tabs-tab:not(.ant-tabs-tab-active) {
span:nth-child(2) {
display: none;
}

.ant-tabs-tab-icon {
margin-inline-end: 0;
}
}

@keyframes fadeIn {
from {
opacity: 0;
}

to {
opacity: 1;
}
}

.ant-tabs-tab.ant-tabs-tab-active {
border-bottom: 2px solid ${token.colorPrimaryActive};
animation: fadeIn .2s;
}
`
}
})
21 changes: 21 additions & 0 deletions assets/js/src/components/editor-tabs/editor-tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { useStyle } from '@Pimcore/components/editor-tabs/editor-tabs.styles'
import { Tabs, type TabsProps } from 'antd'

interface EditorTabsProps {
items: TabsProps['items']
defaultActiveKey?: string
showLabelIfActive?: boolean
}

export const EditorTabs = ({ defaultActiveKey, showLabelIfActive, items }: EditorTabsProps): React.JSX.Element => {
const { styles } = useStyle()

return (
<Tabs
className={`${styles.editorTabs} ${(showLabelIfActive === true) ? styles.onlyActiveLabel : ''}`}
defaultActiveKey={defaultActiveKey}
items={items}
/>
)
}
12 changes: 11 additions & 1 deletion assets/js/src/components/icon/icon.tsx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ const icons = {
'widget-default': React.lazy(async () => await import('@Pimcore/assets/icons/core/widget-default.inline.svg')),
'chevron-up': React.lazy(async () => await import('@Pimcore/assets/icons/core/chevron-up.inline.svg')),
'chevron-down': React.lazy(async () => await import('@Pimcore/assets/icons/core/chevron-down.inline.svg')),
home: React.lazy(async () => await import('@Pimcore/assets/icons/core/home.inline.svg'))
home: React.lazy(async () => await import('@Pimcore/assets/icons/core/home.inline.svg')),
'image-05': React.lazy(async () => await import('@Pimcore/assets/icons/core/image-05.inline.svg')),
edit: React.lazy(async () => await import('@Pimcore/assets/icons/core/edit.inline.svg')),
'data-sheet': React.lazy(async () => await import('@Pimcore/assets/icons/core/data-sheet.inline.svg')),
'data-management-2': React.lazy(async () => await import('@Pimcore/assets/icons/core/data-management-2.inline.svg')),
'history-outlined': React.lazy(async () => await import('@Pimcore/assets/icons/core/history-outlined.inline.svg')),
'schedule-outlined': React.lazy(async () => await import('@Pimcore/assets/icons/core/schedule-outlined.inline.svg')),
hierarchy: React.lazy(async () => await import('@Pimcore/assets/icons/core/hierarchy.inline.svg')),
'view-details': React.lazy(async () => await import('@Pimcore/assets/icons/core/view-details.inline.svg')),
'tag-two-tone': React.lazy(async () => await import('@Pimcore/assets/icons/core/tag-two-tone.inline.svg')),
workflow: React.lazy(async () => await import('@Pimcore/assets/icons/core/workflow.inline.svg'))
}

export interface IconProps {
Expand Down
13 changes: 5 additions & 8 deletions assets/js/src/modules/asset/containers/asset.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { Image } from 'antd'
import { useAssetDraft } from '../hooks/use-asset-draft'
import AssetProvider from '@Pimcore/modules/asset/context/asset-context'
import { EditorTabs } from '@Pimcore/modules/asset/editor-tabs/container/editor-tabs'

export interface AssetProps {
id: string
Expand All @@ -19,13 +20,9 @@ const Asset = (props: AssetProps): React.JSX.Element => {
}

return (
<div>
{asset.filename}

{asset.type === 'image' && (
<Image src={asset.fullPath} />
)}
</div>
<AssetProvider asset={asset}>
<EditorTabs />
</AssetProvider>
)
}

Expand Down
15 changes: 15 additions & 0 deletions assets/js/src/modules/asset/context/asset-context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, { createContext } from 'react'
import type { selectAssetById } from '@Pimcore/modules/asset/store/asset-draft-slice'

export type AssetContextType = ReturnType<typeof selectAssetById>
export const AssetContext = createContext<AssetContextType | null>(null)

const AssetProvider = ({ asset, children }: { asset: ReturnType<typeof selectAssetById>, children: React.ReactNode }): React.JSX.Element => {
return (
<AssetContext.Provider value={asset}>
{children}
</AssetContext.Provider>
)
}

export default AssetProvider
15 changes: 15 additions & 0 deletions assets/js/src/modules/asset/editor-tabs/container/editor-tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import { EditorTabs as EditorTabsView } from '@Pimcore/components/editor-tabs/editor-tabs'
import { assetEditorTabManager } from '@Pimcore/modules/asset/editor-tabs'

export const EditorTabs = (): React.JSX.Element => {
const tabs = assetEditorTabManager.getTabs()

return (
<EditorTabsView
defaultActiveKey={'1'}
items={tabs}
showLabelIfActive={true}
/>
)
}
Loading
Loading