Skip to content

Commit

Permalink
fix: styles (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenphi authored Jan 21, 2025
1 parent 2006cec commit 5dbb99d
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-dragons-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': minor
---

Allow to pass numbers to {min/max}{Width/Height} styles.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-jars-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Fix style property leakage in Panel component.
5 changes: 5 additions & 0 deletions .changeset/hip-plums-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Fix transition aliases.
5 changes: 5 additions & 0 deletions .changeset/neat-seas-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': minor
---

Change default font color to dark-02.
2 changes: 1 addition & 1 deletion src/components/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const BODY_STYLES = {
'-moz-osx-font-smoothing': 'grayscale',
margin: '0',
padding: '0',
color: 'rgba(20, 20, 70, .75)',
color: 'var(--dark-02-color)',
'font-size': '14px',
'line-height': '20px',
'letter-spacing': '0.02em',
Expand Down
8 changes: 4 additions & 4 deletions src/components/actions/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ const ButtonElement = tasty({
'[data-type="clear"] | [data-type="outline"] | [data-type="link"]':
'#purple-text',
'[data-type="link"] & pressed': '#purple',
'[data-type="neutral"]': '#dark.75',
'[data-type="neutral"] & hovered': '#dark.75',
'[data-type="neutral"]': '#dark-02',
'[data-type="neutral"] & hovered': '#dark-02',
'[data-type="neutral"] & pressed': '#purple',

// other
Expand Down Expand Up @@ -198,8 +198,8 @@ const ButtonElement = tasty({
color: {
'': '#white',

'[data-type="neutral"]': '#dark.75',
'[data-type="neutral"] & hovered': '#dark.75',
'[data-type="neutral"]': '#dark-02',
'[data-type="neutral"] & hovered': '#dark-02',
'[data-type="secondary"]': '#danger',
'[data-type="clear"] | [data-type="outline"] | [data-type="link"]':
'#danger-text',
Expand Down
2 changes: 1 addition & 1 deletion src/components/content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ContentElement = tasty({
styles: {
gridArea: 'content',
preset: 'p3',
color: '#dark.75',
color: '#dark-02',
display: 'block',
flow: 'column',
gap: '2x',
Expand Down
2 changes: 1 addition & 1 deletion src/components/content/Paragraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CubeTextProps, Text } from './Text';

const DEFAULT_STYLES: Styles = {
preset: 'p3',
color: '#dark.75',
color: '#dark-02',
display: 'block',
};

Expand Down
1 change: 1 addition & 0 deletions src/components/fields/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const CheckboxWrapperElement = tasty({
preset: 'default',
cursor: 'pointer',
width: 'max max-content',
color: '#dark-02',
},
});

Expand Down
6 changes: 3 additions & 3 deletions src/components/fields/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ const TriggerElement = tasty({
placeItems: 'center',
placeContent: 'center',
placeSelf: 'stretch',
radius: 'right',
radius: '(1r - 1bw) right',
width: '4x',
color: {
'': '#dark.75',
hovered: '#dark.75',
'': '#dark-02',
hovered: '#dark-02',
pressed: '#purple',
'[disabled]': '#dark.30',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const DateRangeDash = tasty({
children: '––',
styles: {
padding: '0 .5x',
color: '#dark-03',
},
});

Expand Down
8 changes: 4 additions & 4 deletions src/components/fields/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ const SelectElement = tasty({
color: {
'': '#white',

'[data-type="secondary"]': '#dark.75',
'[data-type="secondary"] & hovered': '#dark.75',
'[data-type="secondary"]': '#dark-02',
'[data-type="secondary"] & hovered': '#dark-02',
'[data-type="clear"]': '#purple-text',
'[data-type="secondary"] & pressed': '#purple',

Expand Down Expand Up @@ -219,8 +219,8 @@ const OptionElement = tasty({
disabled: '#dark.0',
},
color: {
'': '#dark.75',
'hovered | focused': '#dark.75',
'': '#dark-02',
'hovered | focused': '#dark-02',
'pressed | selected': '#purple',
disabled: '#dark.3',
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/fields/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const SwitchWrapperElement = tasty({
},
gap: '1x',
width: 'max max-content',
color: '#dark-02',
},
});

Expand All @@ -61,6 +62,7 @@ const SwitchLabelElement = tasty({
width: 'min-content',
cursor: 'pointer',
verticalAlign: 'baseline',
color: '#dark-02',
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/fields/TextInput/TextInputBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export const INPUT_WRAPPER_STYLES: Styles = {
radius: true,
cursor: 'text',
color: {
'': '#dark.85',
focused: '#dark.85',
'': '#dark-02',
focused: '#dark-02',
invalid: '#danger-text',
disabled: '#dark.30',
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/FieldWrapper/FieldWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const MessageElement = tasty({
styles: {
preset: 't3',
color: {
'': '#dark.75',
'': '#dark-02',
invalid: '#danger-text',
valid: '#success-text',
disabled: '#dark.40',
Expand Down
2 changes: 2 additions & 0 deletions src/components/layout/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ function Panel(props: CubePanelProps, ref: ForwardedRef<HTMLDivElement>) {
].forEach((style) => {
if (style in props) {
styles = { ...styles, [style]: props[style] };

delete otherProps[style];
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Prefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const PrefixElement = tasty({
left: '@prefix-gap',
top: '@prefix-gap',
bottom: '@prefix-gap',
color: '#dark.75',
color: '#dark-02',
height: '(100% - (2 * @prefix-gap))',
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Suffix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const SuffixElement = tasty({
right: '@suffix-gap',
top: '@suffix-gap',
bottom: '@suffix-gap',
color: '#dark.75',
color: '#dark-02',
height: '(100% - (2 * @suffix-gap))',
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/FileTabs/FileTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const TabElement = tasty(Action, {
'disabled, disabled & hover': '#white',
},
color: {
'': '#dark.75',
'': '#dark-02',
'disabled, hovered, hovered & disabled': '#dark',
},
cursor: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function Modal(allProps: CubeModalProps) {
qa="ModalCloseButton"
width="3x"
height="3x"
color={{ '': '#dark.75', hovered: '#purple' }}
color={{ '': '#dark-02', hovered: '#purple' }}
outline={{
'': '#purple-03.0',
'focused & focus-visible': '#purple-03',
Expand Down
4 changes: 4 additions & 0 deletions src/components/other/Calendar/CalendarGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const TableElement = tasty({
as: 'table',
styles: {
borderCollapse: 'collapse',

HeadRow: {
color: '#dark-04',
},
},
});

Expand Down
6 changes: 3 additions & 3 deletions src/components/overlays/Notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const NotificationElement = tasty(Card, {
role: 'region',
styles: {
display: 'grid',
color: '#dark',
color: '#dark-02',
padding: '.5x',
shadow: '0 5px 15px #dark.10',
border: false,
Expand All @@ -39,7 +39,7 @@ const NotificationElement = tasty(Card, {
placeItems: 'center',
preset: 't2',
color: {
'': '#dark.75',
'': '#dark-02',
...Object.keys(THEMES).reduce((map, theme) => {
map[`[data-theme="${theme}"]`] = THEMES[theme].color;

Expand All @@ -60,7 +60,7 @@ const NotificationElement = tasty(Card, {

const CloseButton = tasty(Action, {
styles: {
color: { '': '#dark.75', hovered: '#purple' },
color: { '': '#dark-02', hovered: '#purple' },
width: '5x',
height: '5x',
label: 'Close',
Expand Down
5 changes: 5 additions & 0 deletions src/tasty/styles/predefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export function predefine() {
defineStyleAlias('right', 'right', numberConverter);
defineStyleAlias('bottom', 'bottom', numberConverter);
defineStyleAlias('left', 'left', numberConverter);
// Dimensions
defineStyleAlias('minWidth', 'min-width', numberConverter);
defineStyleAlias('maxWidth', 'max-width', numberConverter);
defineStyleAlias('minHeight', 'min-height', numberConverter);
defineStyleAlias('maxHeight', 'max-height', numberConverter);
// Style aliases
defineStyleAlias('gridAreas', 'grid-template-areas');
defineStyleAlias('gridColumns', 'grid-template-columns', columnsConverter);
Expand Down
6 changes: 3 additions & 3 deletions src/tasty/styles/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { parseStyle } from '../utils/styles';

const MAP = {
fade: ['mask'],
move: ['transform'],
rotate: ['transform'],
scale: ['transform'],
translate: ['transform', 'translate'],
rotate: ['transform', 'rotate'],
scale: ['transform', 'scale'],
placeSelf: ['transform', 'top', 'right', 'bottom', 'left'],
fill: ['background-color'],
border: ['border', 'box-shadow'],
Expand Down

0 comments on commit 5dbb99d

Please sign in to comment.