Skip to content

Conversation

@RomanPreslitsky
Copy link

@RomanPreslitsky RomanPreslitsky commented Jan 22, 2025

Warning! Work in progress

src/constants.ts Outdated
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' а указать только один раз в конфиге на верхнем уровне


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

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

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

colors: {
'base-brand': 'rgb(94 33 41)',
'base-background': 'rgb(255,255,255)',
'base-brand-hover': 'var(--g-color-private-brand-650-solid)',
Copy link
Contributor

Choose a reason for hiding this comment

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

все эти значения нужно взять из констант, которые ты уже опеределил


describe('Build themer feature', () => {
describe('Apply theme', () => {
generateMapTestTemplate('md2md with theme yaml', '__tests__/mocks/md2md-with-theme-yaml', {
Copy link
Contributor

Choose a reason for hiding this comment

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

давай разделим юнит тесты для самой функции генерации и снепшот тесты результата билда

theme: false,
});

test('should handle arg', "--theme 'note-info-background: rgb(40, 216, 105)'", {
Copy link
Contributor

Choose a reason for hiding this comment

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

через --theme должна быть возможность передать только базовый цвет --theme red, а подробная настройка должна быть через конфиг

@3y3 3y3 force-pushed the master branch 2 times, most recently from 46acb0a to b4bcc4d Compare March 27, 2025 09:41
@3y3 3y3 force-pushed the master branch 9 times, most recently from 52f2688 to 50a4135 Compare September 15, 2025 14:36
@3y3 3y3 force-pushed the master branch 16 times, most recently from 2698a95 to cfe7e59 Compare September 22, 2025 18:21
@3y3 3y3 requested a review from a team as a code owner December 23, 2025 15:29
@3y3 3y3 requested review from goldserg and removed request for a team December 23, 2025 15:29
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.

3 participants