|
1 | 1 | import { styled as createStyled, type Theme } from 'baseui'; |
| 2 | +import { type PanelOverrides } from 'baseui/accordion'; |
| 3 | +import { type BadgeOverrides } from 'baseui/badge'; |
| 4 | +import { type StyleObject } from 'styletron-react'; |
| 5 | + |
| 6 | +import { type WorkflowHistoryEventFilteringType } from '@/views/workflow-history/workflow-history-filters-type/workflow-history-filters-type.types'; |
| 7 | + |
| 8 | +import workflowHistoryEventFilteringTypeColorsConfig from '../config/workflow-history-event-filtering-type-colors.config'; |
| 9 | +import { WORKFLOW_HISTORY_UNGROUPED_GRID_TEMPLATE_COLUMNS } from '../workflow-history-ungrouped-table/workflow-history-ungrouped-table.constants'; |
2 | 10 |
|
3 | 11 | export const styled = { |
4 | | - TempContainer: createStyled('div', ({ $theme }: { $theme: Theme }) => ({ |
5 | | - ...$theme.typography.MonoParagraphXSmall, |
6 | | - padding: $theme.sizing.scale300, |
7 | | - ...$theme.borders.border100, |
| 12 | + HeaderContent: createStyled('div', ({ $theme }: { $theme: Theme }) => ({ |
| 13 | + ...$theme.typography.ParagraphSmall, |
| 14 | + display: 'flex', |
| 15 | + flexDirection: 'column', |
| 16 | + gap: $theme.sizing.scale200, |
| 17 | + paddingBottom: $theme.sizing.scale300, |
| 18 | + [$theme.mediaQuery.medium]: { |
| 19 | + display: 'grid', |
| 20 | + gridTemplateColumns: WORKFLOW_HISTORY_UNGROUPED_GRID_TEMPLATE_COLUMNS, |
| 21 | + width: '100%', |
| 22 | + alignItems: 'center', |
| 23 | + gap: $theme.sizing.scale600, |
| 24 | + paddingBottom: 0, |
| 25 | + }, |
| 26 | + })), |
| 27 | + HeaderLabel: createStyled('div', ({ $theme }: { $theme: Theme }) => ({ |
| 28 | + ...$theme.typography.LabelSmall, |
| 29 | + whiteSpace: 'nowrap', |
| 30 | + textOverflow: 'ellipsis', |
| 31 | + overflow: 'hidden', |
8 | 32 | })), |
| 33 | + StatusContainer: createStyled('div', ({ $theme }: { $theme: Theme }) => ({ |
| 34 | + display: 'flex', |
| 35 | + gap: $theme.sizing.scale300, |
| 36 | + alignItems: 'center', |
| 37 | + })), |
| 38 | + SummarizedDetailsContainer: createStyled( |
| 39 | + 'div', |
| 40 | + ({ $theme }: { $theme: Theme }) => ({ |
| 41 | + overflow: 'hidden', |
| 42 | + [$theme.mediaQuery.medium]: { |
| 43 | + margin: `-${$theme.sizing.scale200} 0`, |
| 44 | + }, |
| 45 | + }) |
| 46 | + ), |
| 47 | + ActionsContainer: createStyled('div', ({ $theme }: { $theme: Theme }) => ({ |
| 48 | + display: 'flex', |
| 49 | + gap: $theme.sizing.scale300, |
| 50 | + alignItems: 'center', |
| 51 | + [$theme.mediaQuery.medium]: { |
| 52 | + margin: `-${$theme.sizing.scale200} 0`, |
| 53 | + }, |
| 54 | + })), |
| 55 | + GroupDetailsGridContainer: createStyled('div', { |
| 56 | + display: 'grid', |
| 57 | + gridTemplateColumns: WORKFLOW_HISTORY_UNGROUPED_GRID_TEMPLATE_COLUMNS, |
| 58 | + }), |
| 59 | + GroupDetailsNameSpacer: createStyled( |
| 60 | + 'div', |
| 61 | + ({ $theme }: { $theme: Theme }) => ({ |
| 62 | + display: 'none', |
| 63 | + [$theme.mediaQuery.medium]: { |
| 64 | + gridColumn: '1 / span 3', |
| 65 | + }, |
| 66 | + }) |
| 67 | + ), |
| 68 | + GroupDetailsContainer: createStyled( |
| 69 | + 'div', |
| 70 | + ({ $theme }: { $theme: Theme }) => ({ |
| 71 | + gridColumn: '1 / -1', |
| 72 | + [$theme.mediaQuery.medium]: { |
| 73 | + gridColumn: '4 / -1', |
| 74 | + }, |
| 75 | + border: `2px solid ${$theme.colors.borderOpaque}`, |
| 76 | + borderRadius: $theme.borders.radius400, |
| 77 | + padding: $theme.sizing.scale500, |
| 78 | + backgroundColor: $theme.colors.backgroundPrimary, |
| 79 | + }) |
| 80 | + ), |
9 | 81 | }; |
| 82 | + |
| 83 | +export const overrides = ( |
| 84 | + eventFilteringType: WorkflowHistoryEventFilteringType, |
| 85 | + animateOnEnter?: boolean |
| 86 | +) => ({ |
| 87 | + panel: { |
| 88 | + PanelContainer: { |
| 89 | + style: ({ $theme }: { $theme: Theme }): StyleObject => ({ |
| 90 | + borderColor: $theme.borders.border100.borderColor, |
| 91 | + borderStyle: $theme.borders.border100.borderStyle, |
| 92 | + borderRadius: 0, |
| 93 | + borderTopWidth: $theme.borders.border100.borderWidth, |
| 94 | + borderBottomWidth: 0, |
| 95 | + borderLeftWidth: 0, |
| 96 | + borderRightWidth: 0, |
| 97 | + marginTop: 0, |
| 98 | + marginBottom: 0, |
| 99 | + overflow: 'hidden', |
| 100 | + }), |
| 101 | + }, |
| 102 | + Header: { |
| 103 | + style: ({ $theme }: { $theme: Theme }): StyleObject => ({ |
| 104 | + // https://github.com/uber/baseweb/blob/main/src/accordion/styled-components.ts#L50 |
| 105 | + // Since the original Panel uses longhand properties, we need to use longhand in overrides |
| 106 | + paddingTop: $theme.sizing.scale300, |
| 107 | + paddingBottom: $theme.sizing.scale300, |
| 108 | + paddingLeft: $theme.sizing.scale300, |
| 109 | + paddingRight: $theme.sizing.scale300, |
| 110 | + backgroundColor: 'inherit', |
| 111 | + display: 'flex', |
| 112 | + alignItems: 'center', |
| 113 | + ':hover': { |
| 114 | + backgroundColor: |
| 115 | + workflowHistoryEventFilteringTypeColorsConfig[eventFilteringType] |
| 116 | + .backgroundHighlighted, |
| 117 | + }, |
| 118 | + ...(animateOnEnter && { |
| 119 | + animationDuration: '2s', |
| 120 | + animationName: { |
| 121 | + from: { |
| 122 | + backgroundColor: |
| 123 | + workflowHistoryEventFilteringTypeColorsConfig[ |
| 124 | + eventFilteringType |
| 125 | + ].backgroundHighlighted, |
| 126 | + }, |
| 127 | + to: { |
| 128 | + backgroundColor: 'inherit', |
| 129 | + }, |
| 130 | + }, |
| 131 | + }), |
| 132 | + }), |
| 133 | + }, |
| 134 | + Content: { |
| 135 | + style: ({ $theme }: { $theme: Theme }): StyleObject => ({ |
| 136 | + // https://github.com/uber/baseweb/blob/main/src/accordion/styled-components.ts#L102 |
| 137 | + // Since the original Panel uses longhand properties, we need to use longhand in overrides |
| 138 | + paddingTop: 0, |
| 139 | + paddingBottom: $theme.sizing.scale600, |
| 140 | + paddingLeft: 0, |
| 141 | + paddingRight: 0, |
| 142 | + [$theme.mediaQuery.medium]: { |
| 143 | + paddingLeft: $theme.sizing.scale700, |
| 144 | + paddingRight: $theme.sizing.scale700, |
| 145 | + }, |
| 146 | + backgroundColor: 'inherit', |
| 147 | + }), |
| 148 | + }, |
| 149 | + ToggleIcon: { |
| 150 | + style: { |
| 151 | + display: 'none', |
| 152 | + }, |
| 153 | + }, |
| 154 | + } satisfies PanelOverrides, |
| 155 | + badge: { |
| 156 | + Badge: { |
| 157 | + style: ({ $theme }: { $theme: Theme }): StyleObject => ({ |
| 158 | + backgroundColor: $theme.colors.backgroundSecondary, |
| 159 | + color: $theme.colors.contentSecondary, |
| 160 | + ...$theme.typography.LabelXSmall, |
| 161 | + whiteSpace: 'nowrap', |
| 162 | + marginLeft: $theme.sizing.scale100, |
| 163 | + }), |
| 164 | + }, |
| 165 | + } satisfies BadgeOverrides, |
| 166 | +}); |
0 commit comments