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

feat: variables generation #334

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/dist
/dist-ssr
/node_modules
/tokens

# Logs
logs
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"serve": "vite preview",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"build-tokens": "token-transformer ./tokens/tokens.json tokens/transformed-tokens.json && node sd.config.mjs",
"lint:js": "eslint '**/*.{vue,ts}'",
"lint:js:fix": "eslint --fix '**/*.{vue,ts,html}'",
"lint:style": "stylelint '**/*.{css,scss,vue}'",
Expand Down Expand Up @@ -74,6 +75,7 @@
"happy-dom": "^3.1.1",
"husky": "^7.0.4",
"lint-staged": "^13.0.3",
"node-sass-alias-importer": "^2.0.0",
"prettier": "^2.6.2",
"release-it": "^15.0.0",
"rollup-plugin-copy": "^3.4.0",
Expand All @@ -83,8 +85,10 @@
"rollup-plugin-vue": "^6.0.0",
"sass": "^1.51.0",
"sass-loader": "^12.6.0",
"style-dictionary": "^3.7.1",
"style-loader": "^3.3.1",
"stylelint": "^14.8.2",
"token-transformer": "^0.0.25",
"typescript": "^4.6.4",
"vite": "^2.9.8",
"vite-plugin-dts": "^1.1.1",
Expand Down
19 changes: 19 additions & 0 deletions sd.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
SeregaBB marked this conversation as resolved.
Show resolved Hide resolved
"source": ["tokens/transformed-tokens.json"],
"platforms": {
"scss": {
"transformGroup": "scss",
"transforms": ["attribute/cti", "name/cti/kebab", "size/px", "color/css"],
"buildPath": "src/",
"files": [
{
"destination": "token-variables.scss",
"format": "scss/map-deep",
"options": {
"showFileHeader": false
}
}
]
}
}
}
49 changes: 49 additions & 0 deletions sd.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* eslint-disable import/no-extraneous-dependencies */
import StyleDictionary from "style-dictionary";
/* eslint-disable import/no-extraneous-dependencies */

const createShadowFromTokenValue = (value) => {
const { x, y, blur, spread, color } = value;

return `${x}px ${y}px ${blur}px ${spread}px ${color}`;
};

const dropShadowTransformer = (token) => {
const tokenValue = token.original.value;
if (!Array.isArray(tokenValue)) return createShadowFromTokenValue(tokenValue);

return token.original.value.reduce((acc, curTokenValue) => {
const shadow = createShadowFromTokenValue(curTokenValue);
acc.push(shadow);

return acc;
}, []).join(', ');

};

StyleDictionary.registerTransform({
type: 'value',
name: 'shadows-value/scss',
matcher: (token) => ['dropShadow', 'boxShadow'].includes(token.type),
transformer: dropShadowTransformer
});

StyleDictionary.extend({
"source": ["tokens/transformed-tokens.json"],
"platforms": {
"scss": {
"transformGroup": "scss",
"transforms": ["attribute/cti", "name/cti/kebab", "size/px", "color/css", "shadows-value/scss"],
"buildPath": "src/",
"files": [
{
"destination": "token-variables.scss",
"format": "scss/variables",
"options": {
"showFileHeader": false
}
}
]
}
}
SeregaBB marked this conversation as resolved.
Show resolved Hide resolved
}).buildAllPlatforms();
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'node-sass-alias-importer';
74 changes: 73 additions & 1 deletion src/main.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,79 @@
@import './normalize';
@import './vars';
@import './transition';

:root {
SeregaBB marked this conversation as resolved.
Show resolved Hide resolved
--color-primary: #de4b7a;
--color-primary-purple: #d048b4;
--color-primary-blue: #4162f0;
--color-primary-blue-light: #74aff8;
--color-primary-blue-aqua: #5ecae7;
--color-primary-darker: #b83e65;
--color-primary-black: #1d1c1a;
--color-secondary-orange: #f95e2d;
--color-secondary-green: #40ba3e;
--color-secondary-yellow: #f2d22b;
--color-accent-secondary-main: #4262f0;
--color-tertiary-white: #fff;
--color-tertiary-gray-ultra-light: #fafafa;
--color-tertiary-gray-lighter: #f4f4f6;
--color-tertiary-gray-light: #f0f0f3;
--color-tertiary-gray: #eaeaea;
--color-tertiary-gray-dark: #e2e2e2;
--color-tertiary-gray-darker: #dadada;
--color-tertiary-gray-ultra-dark: #c4c4c4;
--color-tertiary-gray-ultra-darker: #adacae;
--color-tertiary-gray-ultra-darker-rgb: 173 172 174;
--color-base-regular-rgb: 29 29 27;
--color-rgb-white: 255 255 255;
--color-rgb-blue: 174 174 192;
--color-rgb-gray: 29 28 26;
--color-rgb-primary: 222 75 122;
--gradient-primary: linear-gradient(
101.12deg,
var(--color-primary) 0.76%,
var(--color-primary-purple) 100%
);
--gradient-secondary: linear-gradient(
180deg,
var(--color-primary) -27.44%,
var(--color-primary-blue) 100.54%
);
--box-shadow-primary: -1px -1px 3px rgb(var(--color-rgb-white) / 25%),
1px 1px 3px rgb(var(--color-rgb-blue) / 40%),
4px 4px 8px rgb(var(--color-rgb-blue) / 40%),
-4px -4px 12px var(--color-tertiary-white);
--box-shadow-secondary: -4px -4px 12px var(--color-tertiary-white),
4px 4px 8px rgb(var(--color-rgb-blue) / 40%),
1px 1px 3px rgb(var(--color-rgb-blue) / 40%),
-1px -1px 3px rgb(var(--color-rgb-white) / 25%);
--box-shadow-hover: -1px -1px 4px rgb(var(--color-rgb-white) / 25%),
1px 1px 4px rgb(var(--color-rgb-blue) / 40%),
4px 4px 8px rgb(var(--color-rgb-blue) / 40%),
-4px -4px 8px rgb(var(--color-rgb-white) / 80%);
--box-shadow-pressed: -1px -1px 3px rgb(var(--color-rgb-white) / 25%),
1px 1px 3px rgb(var(--color-rgb-blue) / 40%);
--box-shadow-focus: inset 2px 2px 3px rgb(var(--color-rgb-blue) / 20%),
inset -2px -2px 3px rgb(var(--color-rgb-white) / 70%);
--border-error: 1px solid var(--color-secondary-orange);
--border-radius-base: 4px;

// font
--line-height-base: 22px;
--font-size-base: 14px;
--font-weight-base: 500;
--font-weight-bold: 600;
--letter-spacing-base: 0.03em;

// layout
--layout-gutter: 32px;

// button
--line-height-button: 16px;

// animations
--transition-spline-base: cubic-bezier(0.645, 0.045, 0.355, 1);
}

*,
*::before,
*::after {
Expand Down
81 changes: 40 additions & 41 deletions src/qComponents/QInput/src/q-input.scss
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
.q-input {
--field-color-base: var(--color-primary-black);
--field-color-placeholder: rgb(var(--color-rgb-gray) / 32%);
--field-color-disabled: rgb(var(--color-rgb-gray) / 64%);
--field-icon-color-base: var(--color-primary-blue);
--field-icon-color-hover: var(--color-primary-black);
--field-icon-color-inactive: rgb(var(--color-rgb-gray) / 64%);
--field-background-color-base: var(--color-tertiary-gray-light);
--field-background-color-hover: var(--color-tertiary-gray);
--field-background-color-focus: var(--color-tertiary-gray-ultra-light);
--field-background-color-disabled: var(--color-tertiary-gray);
--field-box-shadow-base: -1px -1px 3px rgb(var(--color-rgb-white) / 25%),
1px 1px 3px rgb(var(--color-rgb-blue) / 40%),
4px 4px 8px rgb(var(--color-rgb-blue) / 40%),
-4px -4px 12px var(--color-tertiary-white);
--field-box-shadow-hover: -1px -1px 4px rgb(var(--color-rgb-white) / 25%),
1px 1px 4px rgb(var(--color-rgb-blue) / 40%),
4px 4px 8px rgb(var(--color-rgb-blue) / 40%),
-4px -4px 8px rgb(var(--color-rgb-white) / 80%);
--field-box-shadow-focus: -1px -1px 3px rgb(var(--color-rgb-white) / 25%),
1px 1px 3px rgb(var(--color-rgb-blue) / 40%),
inset -1px -1px 1px rgb(var(--color-rgb-white) / 70%),
inset 1px 1px 2px rgb(var(--color-rgb-blue) / 20%);
--field-box-shadow-disabled: -1px -1px 3px rgb(var(--color-rgb-white) / 25%),
1px 1px 3px rgb(var(--color-rgb-blue) / 40%);
@import '@/token-variables';
Copy link
Member

Choose a reason for hiding this comment

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

это не нужно и можно дропнуть алиасы


.q-input {
position: relative;
display: inline-block;
width: 100%;
Expand All @@ -37,11 +14,12 @@
font-size: var(--font-size-base);
font-weight: var(--font-weight-base);
line-height: var(--line-height-base);
color: var(--field-color-base);
background-color: var(--field-background-color-base);
color: $input-filled-text-color;
background-color: $input-default-background-color;
border: none;
border-radius: var(--border-radius-base);
box-shadow: var(--field-box-shadow-base);
outline: 1px solid $input-default-border-color;
box-shadow: $input-default-drop-shadow;
appearance: textfield;

&::-webkit-outer-spin-button,
Expand All @@ -52,7 +30,7 @@

&::placeholder,
&:placeholder-shown {
color: var(--field-color-placeholder);
color: $input-disabled-text-color;
text-overflow: ellipsis;
opacity: 1;
}
Expand All @@ -71,21 +49,26 @@

.q-input_focused &,
&.focus-visible {
background-color: var(--field-background-color-focus);
box-shadow: var(--field-box-shadow-focus);
color: $input-focus-filled-text-color;
background-color: $input-filled-background-color;
outline: 1px solid $input-focus-filled-border-color;
box-shadow: $input-focus-drop-shadow;
}

&:hover {
background-color: var(--field-background-color-hover);
box-shadow: var(--field-box-shadow-hover);
color: $input-hover-filled-text-color;
background-color: $input-hover-background-color;
outline: 1px solid $input-hover-border-color;
box-shadow: $input-hover-drop-shadow;
}

.q-input_disabled & {
padding-right: 40px;
color: var(--field-color-disabled);
color: $input-disabled-text-color;
cursor: not-allowed;
background-color: var(--field-background-color-disabled);
box-shadow: var(--field-box-shadow-disabled);
background-color: $input-disabled-background-color;
outline: 1px solid $input-disabled-border-color;
box-shadow: $input-disabled-drop-shadow;
}

.q-input_suffix & {
Expand All @@ -96,7 +79,7 @@
&,
&.focus-visible {
padding-left: 15px;
border: var(--border-error);
outline: 1px solid var(--border-error);
}
}
}
Expand All @@ -116,23 +99,39 @@
width: 40px;
font-size: 24px;
line-height: 40px;
color: var(--field-icon-color-inactive);
color: $input-default-icon-color;
text-align: center;

&:not(:last-child) {
display: none;
}

.q-input_disabled & {
color: $input-disabled-icon-color;
}

.q-input_focused .q-input__inner &,
.q-input__inner.focus-visible & {
color: $input-focus-icon-color;
}

.q-input__inner:hover & {
color: $input-hover-icon-color;
}

&.q-icon-close,
&.q-icon-eye,
&.q-icon-eye-close {
color: var(--field-icon-color-base);
color: $input-filled-icon-color;
pointer-events: all;
cursor: pointer;

&:hover,
&:hover {
color: $input-hover-filled-icon-color;
}

&.focus-visible {
color: var(--field-icon-color-hover);
color: $input-focus-filled-icon-color;
}
}
}
Expand Down
Loading