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

WIP themer #977

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

WIP themer #977

wants to merge 5 commits into from

Conversation

RomanPreslitsky
Copy link

@RomanPreslitsky RomanPreslitsky commented Jan 22, 2025

Warning! Work in progress

src/constants.ts Outdated
@@ -33,6 +33,8 @@ export const TMP_INPUT_FOLDER = '.tmp_input';
export const TMP_OUTPUT_FOLDER = '.tmp_output';
export const MAIN_TIMER_ID = 'Build time';
export const YFM_CONFIG_FILENAME = '.yfm';
export const THEME_CONFIG_FILENAME = 'theme.yaml';
export const THEME_CSS_PATH = '_assets/style/theme.css'; // Какие есть варианты где должен быть этот файл?
Copy link
Contributor

Choose a reason for hiding this comment

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

давай добавим _ чтобы показать, что это не пользовательский файл _theme.css

}
}

function createTheme(configData: ThemeConfig): Theme {
Copy link
Contributor

Choose a reason for hiding this comment

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

строки 'light' и 'dark' будет лучше перенести в константы, они в этом файле часто используются

'note-tip-background',
'note-warning-background',
'note-important-background',
'hljs-addition', // нужно ли давать менять hljs переменные?
Copy link
Contributor

Choose a reason for hiding this comment

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

'hljs-addition', // нужно ли давать менять hljs переменные?

нет

export interface ColorsOptions extends GravityColorsOptions, YFMColorOptions {}

export const YFM_COLOR_KEYS = [
'note-info-background',
Copy link
Contributor

Choose a reason for hiding this comment

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

мало yfm цветов, пробежался по разделу "синтаксис" по доке с со сбилженной темой, нельзя поменять

  • цвет иконок у заметок
  • цвет блока кода
  • линии табов
  • фон и обводка попапов
  • фон у таблиц и тд

посмотри в нашей документации для каких элементов еще можно добавить изменение цвета.
Если у yfm, элемента нет своей css переменной, надо сначала ее добавить в трансформ. И убрать переопределение цвета этого элемента из components.

Copy link
Contributor

Choose a reason for hiding this comment

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

Для каждого элемента в yfm у которого мы меняем цвет должна быть своя переменная. Например, фон попапов --yfm-color-term-dfn-background с оригинальным цветом
https://github.com/diplodoc-platform/transform/blob/master/src/scss/_term.scss#L35

В components мы заменяем оригинальный цвет на цвета из гравити
https://github.com/diplodoc-platform/components/blob/master/src/styles/yfm.scss#L74

тут только должен быть не селектор через dfn, а замена цвет через переменную --yfm-color-term-dfn-background

и уже в клишке когда themer меняет цвет, мы меняем только цвет у переменной --yfm-color-term-dfn-background

light: themeProperties,
dark: themeProperties,
},
required: ['light', 'dark'],
Copy link
Contributor

Choose a reason for hiding this comment

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

'light', 'dark' не должны быть обязательными полями, мы должны иметь возможность указать цвета только для одно из этих значений. Вместе с этим, если цвета для темной и светлой темы одинаковые, должна быть возможность не дублировать их в 'light', 'dark' а указать только один раз в конфиге на верхнем уровне

@@ -47,6 +48,7 @@ export async function handler(run: Run) {

await processChangelogs();

await processThemer(run);
Copy link
Contributor

Choose a reason for hiding this comment

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

наличие конфига не должно быть обязательным, сейчас получаем ошибку если theme.yaml нет в доке


import {resolve} from 'node:path';
import {THEME_CONFIG_FILENAME, THEME_CSS_PATH} from '~/constants';
import * as yaml from 'js-yaml';
Copy link
Contributor

Choose a reason for hiding this comment

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

импортировать стоит только то, что будет использоваться

import { load } from 'js-yaml';

export function createTheme(configData: ThemeConfig): Theme {
const theme: Theme = {};

// if (configData['base-background']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

этот код нужен?

.AfterRun.for('md')
.tapPromise('Themer', async (run) => {
if (isThemeExists(run.input)) {
await run.copy(
Copy link
Contributor

Choose a reason for hiding this comment

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

для md прогона нам тоже нужно сгенерировать css с темой

Copy link
Author

Choose a reason for hiding this comment

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

Так же в ту же папку _assets/style?

@martyanovandrey
Copy link
Contributor

тесты ?

@martyanovandrey
Copy link
Contributor

martyanovandrey commented Feb 18, 2025

не вижу обновлений в трансформе - тебе не пришлось добавить туда ни одной переменной, связанной с цветом?

и к этому ПРу нужно еще добавить ПР с докой для этой фичи

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants