Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/three-bugs-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': minor
---

Migration to modern rgb definition.
5 changes: 5 additions & 0 deletions .changeset/twelve-humans-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Use native css outline for outline style.
6 changes: 3 additions & 3 deletions src/components/organisms/FileTabs/FileTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ const TabElement = tasty(Action, {
fontWeight: 500,
opacity: 1,
preset: 'default',
outline: {
'': 'inset #purple-03.0',
'focused & focus-visible': 'inset #purple-03',
shadow: {
'': 'inset 0 0 0 1ow #purple-03.0',
'focused & focus-visible': 'inset 0 0 0 1ow #purple-03',
},
transform: {
'': 'translate(0, 0)',
Expand Down
1 change: 1 addition & 0 deletions src/tasty/styles/boxShadow.combinator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Deprecated: left as an example
export function boxShadowCombinator(styles) {
const values = boxShadowCombinator.__lookupStyles.reduce(
(list: string[], style) => {
Expand Down
38 changes: 28 additions & 10 deletions src/tasty/styles/outline.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
import { parseStyle } from '../utils/styles';
import { filterMods, parseStyle } from '../utils/styles';

const BORDER_STYLES = [
'none',
'hidden',
'dotted',
'dashed',
'solid',
'double',
'groove',
'ridge',
'inset',
'outset',
];

/**
*
* @param outline
* @return {{outline: string}|*}
*/
export function outlineStyle({ outline }) {
if (!outline && outline !== 0) return '';
if (!outline && outline !== 0) return;

if (outline === true) outline = '1ow';

const { values, color, mods } = parseStyle(String(outline));
const { values, mods, color } = parseStyle(String(outline));

const typeMods = filterMods(mods, BORDER_STYLES);

const inset = mods.includes('inset');
const size = values[0] || 'var(--outline-width)';
const value = values[0] || 'var(--outline-width)';
const type = typeMods[0] || 'solid';
const outlineColor = color || 'var(--outline-color)';

return {
'--local-outline-box-shadow': `${
inset ? 'inset ' : ''
}0 0 0 ${size} ${outlineColor}`,
};
const styleValue = [value, type, outlineColor].join(' ');

return { outline: styleValue };
}

outlineStyle.__lookupStyles = ['outline'];
4 changes: 2 additions & 2 deletions src/tasty/styles/predefined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { fontStyle } from './font';
import { outlineStyle } from './outline';
import { transitionStyle } from './transition';
import { groupRadiusAttr } from './groupRadius';
import { boxShadowCombinator } from './boxShadow.combinator';
import { styledScrollbarStyle } from './styledScrollbar';
import { displayStyle } from './display';
import { alignStyle } from './align';
Expand Down Expand Up @@ -149,6 +148,8 @@ export function predefine() {
.map((s, i) => (i ? columnsConverter : rowsConverter)(s))
.join('/');
});
// Other styles
defineStyleAlias('outlineOffset', 'outlineOffset', numberConverter);

[
displayStyle,
Expand All @@ -172,7 +173,6 @@ export function predefine() {
alignStyle,
justifyStyle,
presetStyle,
boxShadowCombinator,
outlineStyle,
fontStyle,
fontStyleStyle,
Expand Down
2 changes: 1 addition & 1 deletion src/tasty/styles/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function shadowStyle({ shadow }) {
if (shadow === true) shadow = '0 5px 15px #shadow';

return {
'--local-shadow-box-shadow': shadow.split(',').map(toBoxShadow).join(','),
'box-shadow': shadow.split(',').map(toBoxShadow).join(','),
};
}

Expand Down
Loading