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

fix(Datamapper-styles): fix the PF tokens and tweak DnD styling #1927

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion packages/ui-tests/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { StorybookConfig } from '@storybook/react-vite';

import { dirname, join } from 'path';
import { dirname, join, resolve } from 'path';
import packageJson from '../../../package.json';

/**
Expand Down Expand Up @@ -54,6 +54,14 @@ const config: StorybookConfig = {
},
},
},
resolve: {
alias: [
{
find: /~(.*)/,
replacement: '$1',
},
],
},
};
},
};
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/src/components/DataMapper/debug/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,15 @@ export default defineConfig(async () => {
},
},
},
resolve: {
alias: [
{
find: /^~.+/,
replacement: (val) => {
Copy link
Member

Choose a reason for hiding this comment

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

we're using vite also in storybook, so it would probably be convenient to normalize these configs.

return val.replace(/^~/, '');
},
},
],
},
};
});
5 changes: 3 additions & 2 deletions packages/ui/src/components/Document/Document.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

&__header,
&__children {
border-bottom: 1px solid var(--pf-v6-global--palette--black-300);
border-left: 1px solid var(--pf-v6-global--palette--black-300);
border-bottom: 1px solid var(--pf-t--global--color--disabled--100);
border-left: 1px solid var(--pf-t--global--color--disabled--100);
padding-left: var(--pf-t--global--spacer--md);
border-bottom-left-radius: var(--pf-v6-c-panel--BorderRadius);
}

&__children {
Expand Down
22 changes: 13 additions & 9 deletions packages/ui/src/components/Document/NodeContainer.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
@use '../../styles/dnd';

.droppable-container {
color: var(--pf-v6-global--primary-color--200);
border-width: thin;
border-style: dashed;
border-color: var(--pf-v6-global--primary-color--200);
background-color: var(--pf-v6-global--palette--blue-50);
color: var(--pf-t--global--text--color--regular);
border-width: var(--pf-v6-c-draggable--m-dragging--after--BorderWidth);
border-style: solid;
border-color: var(--pf-v6-c-droppable--m-dragging--after--BorderColor);
background-color: var(--pf-v6-c-droppable-m-dragging--BackgroundColor);
border-radius: var(--pf-v6-c-droppable--m-dragging--after--BorderRadius);
box-sizing: border-box;
}

.draggable-container {
font-weight: bold;
color: var(--pf-v6-global--primary-color--100);
border-width: thin;
color: var(--pf-t--global--icon--color--brand--default);
border-style: solid;
border-color: var(--pf-v6-global--primary-color--200);
background-color: var(--pf-v6-global--palette--black-200);
border-width: var(--pf-v6-c-draggable--m-dragging--after--BorderWidth);
border-color: var(--pf-v6-c-draggable--m-dragging--after--BorderColor);
background-color: var(--pf-v6-c-draggable--m-dragging--BackgroundColor);
border-radius: var(--pf-v6-c-draggable--m-dragging--after--BorderRadius);
box-sizing: border-box;

@include dnd.cursor-grab;
}
4 changes: 2 additions & 2 deletions packages/ui/src/components/Document/NodeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const DroppableContainer: FunctionComponent<BaseContainerProps> = ({ clas
<div
id={`droppable-${id}`}
ref={setDroppableNodeRef}
className={clsx(className, { 'droppable-container': isOver })}
className={clsx(className, { 'droppable-container': isOver }, 'pf-v6-c-droppable')}
>
{children}
</div>
Expand All @@ -48,7 +48,7 @@ export const DraggableContainer: FunctionComponent<BaseContainerProps> = ({ id,
<div
id={`draggable-${id}`}
ref={setDraggableNodeRef}
className={clsx({ 'draggable-container': isDefined(transform) })}
className={clsx({ 'draggable-container': isDefined(transform) }, 'pf-v6-c-draggable')}
{...listeners}
{...attributes}
>
Expand Down
17 changes: 17 additions & 0 deletions packages/ui/src/providers/datamapper-dnd.provider.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@use '../styles/dnd';

.dragging-container {
padding: 5px;
font-weight: bold;
color: var(--pf-t--global--icon--color--brand--default);
border-style: solid;
border-width: 2px;
border-color: var(--pf-v6-c-draggable--m-dragging--after--BorderColor);
background-color: var(--pf-t--global--background--color--100);
border-radius: var(--pf-v6-c-draggable--m-dragging--after--BorderRadius);
box-shadow: var(--pf-v6-c-draggable--m-dragging--BoxShadow);
}

.pf-v6-c-draggable.dragging-container {
cursor: grabbing;
}
5 changes: 4 additions & 1 deletion packages/ui/src/providers/datamapper-dnd.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { NodeData } from '../models/datamapper';
import { Label } from '@patternfly/react-core';
import { useDataMapper } from '../hooks/useDataMapper';
import { DataMapperDnDMonitor } from './dnd/DataMapperDndMonitor';
import './datamapper-dnd.provider.scss';

export interface IDataMapperDndContext {
handler?: DnDHandler;
Expand Down Expand Up @@ -80,7 +81,9 @@ export const DatamapperDndProvider: FunctionComponent<DataMapperDndContextProps>
<DndContext sensors={sensors} onDragStart={handleDragStart} onDragOver={handleDragOver} onDragEnd={handleDragEnd}>
{props.children}
<DragOverlay dropAnimation={null}>
<Label>{activeData?.current?.title ? activeData.current.title : 'dragging...'}</Label>
<div className={'pf-v6-c-draggable node__row dragging-container'}>
<Label>{activeData?.current?.title ? activeData.current.title : 'dragging...'}</Label>
</div>
</DragOverlay>
{debug && <DataMapperDnDMonitor />}
</DndContext>
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/styles/_dnd.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@forward '~@patternfly/patternfly/components/DragDrop/drag-drop.scss';
Copy link
Member

Choose a reason for hiding this comment

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

@mmelko @igarashitm
We're reexporting the drag-drop.scss styles and variables from patternfly so they are available to the users of this mixin.


@mixin cursor-grab {
cursor: grab;

Expand Down
10 changes: 10 additions & 0 deletions packages/ui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@ export default defineConfig(async () => {
},
},
},
resolve: {
alias: [
{
find: /^~.+/,
replacement: (val) => {
return val.replace(/^~/, '');
},
},
],
},
};
});
Loading