Tokens for Org Chart

pull/5756/head
Cagatay Civici 2024-05-12 02:38:12 +03:00
parent 4f617533fb
commit f1d01dd4d5
3 changed files with 77 additions and 31 deletions

View File

@ -10,7 +10,7 @@ const theme = ({ dt }) => `
.p-organizationchart-table > tbody > tr > td { .p-organizationchart-table > tbody > tr > td {
text-align: center; text-align: center;
vertical-align: top; vertical-align: top;
padding: 0 0.75rem; padding: 0 ${dt('organizationchart.gutter')};
} }
.p-organizationchart-node { .p-organizationchart-node {
@ -19,50 +19,56 @@ const theme = ({ dt }) => `
border: 1px solid ${dt('organizationchart.node.border.color')}; border: 1px solid ${dt('organizationchart.node.border.color')};
background: ${dt('organizationchart.node.background')}; background: ${dt('organizationchart.node.background')};
color: ${dt('organizationchart.node.color')}; color: ${dt('organizationchart.node.color')};
padding: 0.75rem 1rem; padding: ${dt('organizationchart.node.padding')};
border-radius: ${dt('border.radius.md')}; border-radius: ${dt('organizationchart.node.border.radius')};
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}; transition: background ${dt('transition.duration')}, border-color ${dt('transition.duration')}, color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')};
} }
.p-organizationchart-node:has(.p-organizationchart-node-toggle-button) { .p-organizationchart-node:has(.p-organizationchart-node-toggle-button) {
padding: 0.75rem 1rem 1.25rem 1rem; padding: ${dt('organizationchart.node.toggleable.padding')};
} }
.p-organizationchart-node.p-organizationchart-node-selectable:not(.p-highlight):hover { .p-organizationchart-node.p-organizationchart-node-selectable:not(.p-organizationchart-node-selected):hover {
background: ${dt('organizationchart.node.hover.background')}; background: ${dt('organizationchart.node.hover.background')};
color: ${dt('organizationchart.node.hover.color')}; color: ${dt('organizationchart.node.hover.color')};
} }
.p-organizationchart-node.p-highlight { .p-organizationchart-node-selected {
background: ${dt('highlight.background')}; background: ${dt('organizationchart.node.selected.background')};
color: ${dt('highlight.color')}; color: ${dt('organizationchart.node.selected.color')};
} }
.p-organizationchart-node-toggle-button { .p-organizationchart-node-toggle-button {
position: absolute; position: absolute;
bottom: -0.75rem; bottom: calc(-1 * calc(${dt('organizationchart.node.toggle.button.size')} / 2));
margin-left: -0.75rem; margin-left: calc(-1 * calc(${dt('organizationchart.node.toggle.button.size')} / 2));
z-index: 2; z-index: 2;
left: 50%; left: 50%;
user-select: none; user-select: none;
cursor: pointer; cursor: pointer;
width: 1.5rem; width: ${dt('organizationchart.node.toggle.button.size')};
height: 1.5rem; height: ${dt('organizationchart.node.toggle.button.size')};
text-decoration: none; text-decoration: none;
background: ${dt('organizationchart.node.toggle.button.background')}; background: ${dt('organizationchart.node.toggle.button.background')};
color: ${dt('organizationchart.node.toggle.button.color')}; color: ${dt('organizationchart.node.toggle.button.color')};
border-radius: 50%; border-radius: ${dt('organizationchart.node.toggle.button.border.radius')};
border: 1px solid ${dt('organizationchart.node.toggle.button.border.color')}; border: 1px solid ${dt('organizationchart.node.toggle.button.border.color')};
display: inline-flex; display: inline-flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
outline-color: transparent; outline-color: transparent;
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}; transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, border-color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')};
}
.p-organizationchart-node-toggle-button:hover {
background: ${dt('organizationchart.node.toggle.button.hover.background')};
color: ${dt('organizationchart.node.toggle.button.hover.color')};
} }
.p-organizationchart-node-toggle-button:focus-visible { .p-organizationchart-node-toggle-button:focus-visible {
outline: ${dt('focus.ring.width')} ${dt('focus.ring.style')} ${dt('focus.ring.color')}; box-shadow: ${dt('breadcrumb.item.focus.ring.shadow')};
outline-offset: ${dt('focus.ring.offset')}; outline: ${dt('breadcrumb.item.focus.ring.width')} ${dt('breadcrumb.item.focus.ring.style')} ${dt('breadcrumb.item.focus.ring.color')};
outline-offset: ${dt('breadcrumb.item.focus.ring.offset')};
} }
.p-organizationchart-node-toggle-button-icon { .p-organizationchart-node-toggle-button-icon {
@ -72,15 +78,13 @@ const theme = ({ dt }) => `
.p-organizationchart-connector-down { .p-organizationchart-connector-down {
margin: 0 auto; margin: 0 auto;
height: 20px; height: ${dt('organizationchart.connector.height')};
width: 1px; width: 1px;
background: ${dt('organizationchart.connector.color')}; background: ${dt('organizationchart.connector.color')};
} }
.p-organizationchart-connector-right { .p-organizationchart-connector-right {
border-radius: 0; border-radius: 0;
border-left: 1px solid ${dt('organizationchart.connector.color')};
border-top-left-radius: ${dt('border.radius.md')};
} }
.p-organizationchart-connector-left { .p-organizationchart-connector-left {
@ -101,19 +105,19 @@ const theme = ({ dt }) => `
} }
.p-organizationchart-connectors :nth-last-child(1 of .p-organizationchart-connector-left) { .p-organizationchart-connectors :nth-last-child(1 of .p-organizationchart-connector-left) {
border-top-right-radius: ${dt('border.radius.md')}; border-top-right-radius: ${dt('organizationchart.connector.border.radius')};
} }
.p-organizationchart-connectors :nth-child(1 of .p-organizationchart-connector-right) { .p-organizationchart-connectors :nth-child(1 of .p-organizationchart-connector-right) {
border-left: 1px solid ${dt('organizationchart.connector.color')}; border-left: 1px solid ${dt('organizationchart.connector.color')};
border-top-left-radius: ${dt('border.radius.md')}; border-top-left-radius: ${dt('organizationchart.connector.border.radius')};
} }
`; `;
const classes = { const classes = {
root: 'p-organizationchart p-component', root: 'p-organizationchart p-component',
table: 'p-organizationchart-table', table: 'p-organizationchart-table',
node: ({ instance }) => ['p-organizationchart-node', { 'p-organizationchart-node-selectable': instance.selectable, 'p-highlight': instance.selected }], node: ({ instance }) => ['p-organizationchart-node', { 'p-organizationchart-node-selectable': instance.selectable, 'p-organizationchart-node-selected': instance.selected }],
nodeToggleButton: 'p-organizationchart-node-toggle-button', nodeToggleButton: 'p-organizationchart-node-toggle-button',
nodeToggleButtonIcon: 'p-organizationchart-node-toggle-button-icon', nodeToggleButtonIcon: 'p-organizationchart-node-toggle-button-icon',
connectors: 'p-organizationchart-connectors', connectors: 'p-organizationchart-connectors',

View File

@ -1,17 +1,38 @@
export default { export default {
root: {
gutter: '0.75rem'
},
node: { node: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}', hoverBackground: '{content.hover.background}',
selectedBackground: '{highlight.background}',
borderColor: '{content.border.color}', borderColor: '{content.border.color}',
color: '{text.color}', color: '{content.color}',
hoverColor: '{text.hover.color}' selectedColor: '{highlight.color}',
hoverColor: '{content.hover.color}',
padding: '0.75rem 1rem',
toggleablePadding: '0.75rem 1rem 1.25rem 1rem',
borderRadius: '{content.border.radius}'
}, },
nodeToggleButton: { nodeToggleButton: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}',
borderColor: '{content.border.color}', borderColor: '{content.border.color}',
color: '{text.muted.color}' color: '{text.muted.color}',
hoverColor: '{text.color}',
size: '1.5rem',
borderRadius: '50%',
focusRing: {
width: '{focus.ring.width}',
style: '{focus.ring.style}',
color: '{focus.ring.color}',
offset: '{focus.ring.offset}',
shadow: '{focus.ring.shadow}'
}
}, },
connector: { connector: {
color: '{content.border.color}' color: '{content.border.color}',
borderRadius: '{content.border.radius}',
height: '24px'
} }
}; };

View File

@ -1,17 +1,38 @@
export default { export default {
root: {
gutter: '0.75rem'
},
node: { node: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}', hoverBackground: '{content.hover.background}',
selectedBackground: '{highlight.background}',
borderColor: '{content.border.color}', borderColor: '{content.border.color}',
color: '{text.color}', color: '{content.color}',
hoverColor: '{text.hover.color}' selectedColor: '{highlight.color}',
hoverColor: '{content.hover.color}',
padding: '1rem 1.25rem',
toggleablePadding: '1rem 1.25rem 1.5rem 1.25rem',
borderRadius: '{content.border.radius}'
}, },
nodeToggleButton: { nodeToggleButton: {
background: '{content.background}', background: '{content.background}',
hoverBackground: '{content.hover.background}',
borderColor: '{content.border.color}', borderColor: '{content.border.color}',
color: '{text.muted.color}' color: '{text.muted.color}',
hoverColor: '{text.color}',
size: '1.75rem',
borderRadius: '50%',
focusRing: {
width: '{focus.ring.width}',
style: '{focus.ring.style}',
color: '{focus.ring.color}',
offset: '{focus.ring.offset}',
shadow: '{focus.ring.shadow}'
}
}, },
connector: { connector: {
color: '{content.border.color}' color: '{content.border.color}',
borderRadius: '{content.border.radius}',
height: '24px'
} }
}; };