From bee1fe3fd82cf7090db4df1efb94f2a25f604252 Mon Sep 17 00:00:00 2001 From: Paul Gascou-Vaillancourt <pgascouvaillancourt@gitlab.com> Date: Thu, 18 Apr 2024 15:47:04 +0000 Subject: [PATCH] Add font families to Tailwind config The monospace font needs to be defined via a plugin so that we can disable ligatures. This in turn requires that we slightly adjust the CSS-in-Js generator so that it takes this plugin into account when creating and purging the config. --- .../components/path_navigation.vue | 2 +- .../components/ci_variable_drawer.vue | 2 +- .../components/commit/commit_form.vue | 4 ++-- .../components/node_error_help_text.vue | 2 +- .../components/deploy_freeze_modal.vue | 4 ++-- .../incidents/timeline_events_form.vue | 2 +- .../experiments/show/ml_experiments_show.vue | 6 +++--- .../components/list_page/project_empty_state.vue | 6 +++--- .../container_expiration_policy_form.vue | 2 +- .../repository/components/commit_info.vue | 2 +- .../components/diff_stats_dropdown.vue | 2 +- .../form/input_copy_toggle_visibility.vue | 3 ++- .../components/user_popover/user_popover.vue | 2 +- .../components/work_item_description.vue | 2 +- config/tailwind.config.js | 16 ++++++++++++++++ .../components/included_in_trial_indicator.vue | 2 +- .../components/add_on_eligible_user_list.vue | 2 +- .../seats/components/subscription_user_list.vue | 2 +- .../components/solution_card.vue | 2 +- .../__snapshots__/learn_gitlab_spec.js.snap | 10 +++++----- scripts/frontend/tailwind_all_the_way.mjs | 14 +++++++++++--- .../project_empty_state_spec.js.snap | 6 +++--- .../repository/components/commit_info_spec.js | 2 +- 23 files changed, 61 insertions(+), 36 deletions(-) diff --git a/app/assets/javascripts/analytics/cycle_analytics/components/path_navigation.vue b/app/assets/javascripts/analytics/cycle_analytics/components/path_navigation.vue index d305132ae336d..db87286576815 100644 --- a/app/assets/javascripts/analytics/cycle_analytics/components/path_navigation.vue +++ b/app/assets/javascripts/analytics/cycle_analytics/components/path_navigation.vue @@ -83,7 +83,7 @@ export default { </div> </div> <div class="gl-px-4"> - <div class="gl-pb-3 gl-font-style-italic"> + <div class="gl-pb-3 gl-italic"> {{ s__('ValueStreamEvent|Only items that reached their stop event.') }} </div> </div> diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue index 3ff356f5e5b1f..b85e91375d414 100644 --- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue +++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_drawer.vue @@ -557,7 +557,7 @@ export default { id="ci-variable-value" v-model="variable.value" :spellcheck="false" - class="gl-border-none gl-font-monospace!" + class="gl-border-none !gl-font-monospace" rows="5" :no-resize="false" data-testid="ci-variable-value" diff --git a/app/assets/javascripts/ci/pipeline_editor/components/commit/commit_form.vue b/app/assets/javascripts/ci/pipeline_editor/components/commit/commit_form.vue index baf3dbfa090d7..88f0c79f1a61b 100644 --- a/app/assets/javascripts/ci/pipeline_editor/components/commit/commit_form.vue +++ b/app/assets/javascripts/ci/pipeline_editor/components/commit/commit_form.vue @@ -113,7 +113,7 @@ export default { <gl-form-textarea id="commit-message" v-model="message" - class="gl-font-monospace!" + class="!gl-font-monospace" required :placeholder="defaultMessage" /> @@ -126,7 +126,7 @@ export default { <gl-form-input id="source-branch-field" v-model="sourceBranch" - class="gl-font-monospace!" + class="!gl-font-monospace" required data-testid="source-branch-field" /> diff --git a/app/assets/javascripts/clusters_list/components/node_error_help_text.vue b/app/assets/javascripts/clusters_list/components/node_error_help_text.vue index 9903a1bdb3e56..82d079068f435 100644 --- a/app/assets/javascripts/clusters_list/components/node_error_help_text.vue +++ b/app/assets/javascripts/clusters_list/components/node_error_help_text.vue @@ -28,7 +28,7 @@ export default { <template> <div :id="popoverId"> - <span class="gl-font-style-italic"> + <span class="gl-italic"> {{ errorContent.tableText }} </span> diff --git a/app/assets/javascripts/deploy_freeze/components/deploy_freeze_modal.vue b/app/assets/javascripts/deploy_freeze/components/deploy_freeze_modal.vue index 6210e82119f73..fa5b48586308c 100644 --- a/app/assets/javascripts/deploy_freeze/components/deploy_freeze_modal.vue +++ b/app/assets/javascripts/deploy_freeze/components/deploy_freeze_modal.vue @@ -141,7 +141,7 @@ export default { id="deploy-freeze-start" ref="freezeStartCron" v-model="freezeStartCron" - class="gl-font-monospace!" + class="!gl-font-monospace" :placeholder="$options.i18n.cronPlaceholder" :state="freezeStartCronState" autofocus @@ -158,7 +158,7 @@ export default { <gl-form-input id="deploy-freeze-end" v-model="freezeEndCron" - class="gl-font-monospace!" + class="!gl-font-monospace" :placeholder="$options.i18n.cronPlaceholder" :state="freezeEndCronState" trim diff --git a/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue b/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue index 6f62dae647c36..6d2bdd60567aa 100644 --- a/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue +++ b/app/assets/javascripts/issues/show/components/incidents/timeline_events_form.vue @@ -237,7 +237,7 @@ export default { <template #textarea> <gl-form-textarea v-model="timelineText" - class="note-textarea-rounded-bottom js-gfm-input js-autosize markdown-area gl-font-monospace!" + class="note-textarea-rounded-bottom js-gfm-input js-autosize markdown-area !gl-font-monospace" data-testid="input-note" dir="auto" data-supports-quick-actions="false" diff --git a/app/assets/javascripts/ml/experiment_tracking/routes/experiments/show/ml_experiments_show.vue b/app/assets/javascripts/ml/experiment_tracking/routes/experiments/show/ml_experiments_show.vue index f492c3ec3585e..ef0b29ef0f6c5 100644 --- a/app/assets/javascripts/ml/experiment_tracking/routes/experiments/show/ml_experiments_show.vue +++ b/app/assets/javascripts/ml/experiment_tracking/routes/experiments/show/ml_experiments_show.vue @@ -206,7 +206,7 @@ export default { <template #cell(nameColumn)="data"> <gl-link :href="data.value.details_path"> <span v-if="data.value.name"> {{ data.value.name }}</span> - <span v-else class="gl-font-style-italic">{{ $options.i18n.NO_CANDIDATE_NAME }}</span> + <span v-else class="gl-italic">{{ $options.i18n.NO_CANDIDATE_NAME }}</span> </gl-link> </template> @@ -214,7 +214,7 @@ export default { <gl-link v-if="data.value" :href="data.value" target="_blank">{{ $options.i18n.ARTIFACTS_LABEL }}</gl-link> - <div v-else class="gl-font-style-italic gl-text-gray-500"> + <div v-else class="gl-italic gl-text-gray-500"> {{ $options.i18n.NO_ARTIFACT }} </div> </template> @@ -232,7 +232,7 @@ export default { <gl-link v-if="data.value" :href="data.value.path" target="_blank">{{ data.value.name }}</gl-link> - <div v-else class="gl-font-style-italic gl-text-gray-500"> + <div v-else class="gl-italic gl-text-gray-500"> {{ $options.i18n.NO_JOB }} </div> </template> diff --git a/app/assets/javascripts/packages_and_registries/container_registry/explorer/components/list_page/project_empty_state.vue b/app/assets/javascripts/packages_and_registries/container_registry/explorer/components/list_page/project_empty_state.vue index 4ddcaa5c9a76f..ee11a8740db3a 100644 --- a/app/assets/javascripts/packages_and_registries/container_registry/explorer/components/list_page/project_empty_state.vue +++ b/app/assets/javascripts/packages_and_registries/container_registry/explorer/components/list_page/project_empty_state.vue @@ -69,7 +69,7 @@ export default { :value="dockerLoginCommand" readonly type="text" - class="gl-font-monospace!" + class="!gl-font-monospace" /> <template #append> <clipboard-button @@ -87,7 +87,7 @@ export default { :value="dockerBuildCommand" readonly type="text" - class="gl-font-monospace!" + class="!gl-font-monospace" /> <template #append> <clipboard-button @@ -98,7 +98,7 @@ export default { </template> </gl-form-input-group> <gl-form-input-group> - <gl-form-input :value="dockerPushCommand" readonly type="text" class="gl-font-monospace!" /> + <gl-form-input :value="dockerPushCommand" readonly type="text" class="!gl-font-monospace" /> <template #append> <clipboard-button :text="dockerPushCommand" diff --git a/app/assets/javascripts/packages_and_registries/settings/project/components/container_expiration_policy_form.vue b/app/assets/javascripts/packages_and_registries/settings/project/components/container_expiration_policy_form.vue index c13d49b53797e..97b2327feea7a 100644 --- a/app/assets/javascripts/packages_and_registries/settings/project/components/container_expiration_policy_form.vue +++ b/app/assets/javascripts/packages_and_registries/settings/project/components/container_expiration_policy_form.vue @@ -306,7 +306,7 @@ export default { > {{ __('Cancel') }} </gl-button> - <span class="gl-font-style-italic gl-text-gray-500">{{ + <span class="gl-italic gl-text-gray-500">{{ $options.i18n.EXPIRATION_POLICY_FOOTER_NOTE }}</span> </div> diff --git a/app/assets/javascripts/repository/components/commit_info.vue b/app/assets/javascripts/repository/components/commit_info.vue index 3e46999ef8619..29d71f3e11718 100644 --- a/app/assets/javascripts/repository/components/commit_info.vue +++ b/app/assets/javascripts/repository/components/commit_info.vue @@ -95,7 +95,7 @@ export default { <gl-link v-safe-html:[$options.safeHtmlConfig]="commit.titleHtml" :href="commit.webPath" - :class="{ 'gl-font-style-italic': !commit.message }" + :class="{ 'gl-italic': !commit.message }" class="commit-row-message item-title gl-line-clamp-1 gl-word-break-all!" /> <gl-button diff --git a/app/assets/javascripts/vue_shared/components/diff_stats_dropdown.vue b/app/assets/javascripts/vue_shared/components/diff_stats_dropdown.vue index 55767c5f4bccd..1ce47b0620b56 100644 --- a/app/assets/javascripts/vue_shared/components/diff_stats_dropdown.vue +++ b/app/assets/javascripts/vue_shared/components/diff_stats_dropdown.vue @@ -124,7 +124,7 @@ export default { <div class="gl-display-flex"> <span class="gl-font-weight-bold gl-mr-3 gl-flex-grow-1" - :class="item.name ? 'gl-text-truncate' : 'gl-font-style-italic gl-gray-400'" + :class="item.name ? 'gl-text-truncate' : 'gl-italic gl-gray-400'" >{{ item.text }}</span > <span class="gl-ml-auto gl-white-space-nowrap" aria-hidden="true"> diff --git a/app/assets/javascripts/vue_shared/components/form/input_copy_toggle_visibility.vue b/app/assets/javascripts/vue_shared/components/form/input_copy_toggle_visibility.vue index b03da19a8962e..d007d8507e970 100644 --- a/app/assets/javascripts/vue_shared/components/form/input_copy_toggle_visibility.vue +++ b/app/assets/javascripts/vue_shared/components/form/input_copy_toggle_visibility.vue @@ -96,7 +96,8 @@ export default { }, formInputClass() { return [ - 'gl-font-monospace! gl-cursor-default!', + // eslint-disable-next-line @gitlab/require-i18n-strings + '!gl-font-monospace gl-cursor-default!', { 'input-copy-show-disc': !this.computedValueIsVisible }, this.formInputGroupProps.class, ]; diff --git a/app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue b/app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue index e53e81ec98e0d..0a3d32e59f1dc 100644 --- a/app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue +++ b/app/assets/javascripts/vue_shared/components/user_popover/user_popover.vue @@ -227,7 +227,7 @@ export default { class="gl-w-full" > <template v-if="isBlocked"> - <span class="gl-mt-4 gl-font-style-italic">{{ $options.I18N_USER_BLOCKED }}</span> + <span class="gl-mt-4 gl-italic">{{ $options.I18N_USER_BLOCKED }}</span> </template> <template v-else> <gl-button diff --git a/app/assets/javascripts/work_items/components/work_item_description.vue b/app/assets/javascripts/work_items/components/work_item_description.vue index 3470b31545e15..3de999457db9f 100644 --- a/app/assets/javascripts/work_items/components/work_item_description.vue +++ b/app/assets/javascripts/work_items/components/work_item_description.vue @@ -316,7 +316,7 @@ export default { <details class="gl-mb-5"> <summary class="gl-text-blue-500">{{ s__('WorkItem|View current version') }}</summary> <gl-form-textarea - class="js-gfm-input js-autosize markdown-area gl-font-monospace!" + class="js-gfm-input js-autosize markdown-area !gl-font-monospace" data-testid="conflicted-description" readonly :value="conflictedDescription" diff --git a/config/tailwind.config.js b/config/tailwind.config.js index 628f99cd2a872..5054574a3fa39 100644 --- a/config/tailwind.config.js +++ b/config/tailwind.config.js @@ -23,6 +23,16 @@ try { delete require.cache[path.resolve(__filename)]; } +function gitLabUIUtilities({ addUtilities }) { + addUtilities({ + '.font-monospace': { + 'font-family': + 'var(--default-mono-font, "GitLab Mono"), "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace', + 'font-variant-ligatures': 'none', + }, + }); +} + /** @type {import('tailwindcss').Config} */ module.exports = { presets: [tailwindDefaults], @@ -78,6 +88,11 @@ module.exports = { preflight: false, }, theme: { + // TODO: Backport to GitLab UI + fontFamily: { + regular: + 'var(--default-regular-font, "GitLab Sans"), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', + }, // These extends probably should be moved to GitLab UI: extend: { borderWidth: { @@ -99,6 +114,7 @@ module.exports = { }, }, plugins: [ + plugin(gitLabUIUtilities), plugin(({ addUtilities }) => { addUtilities(utilities); }), diff --git a/ee/app/assets/javascripts/pages/projects/learn_gitlab/components/included_in_trial_indicator.vue b/ee/app/assets/javascripts/pages/projects/learn_gitlab/components/included_in_trial_indicator.vue index 693dc6a15adeb..40973f76bf5e8 100644 --- a/ee/app/assets/javascripts/pages/projects/learn_gitlab/components/included_in_trial_indicator.vue +++ b/ee/app/assets/javascripts/pages/projects/learn_gitlab/components/included_in_trial_indicator.vue @@ -9,7 +9,7 @@ export default { }; </script> <template> - <span class="gl-font-style-italic gl-text-gray-500" data-testid="trial-only"> + <span class="gl-italic gl-text-gray-500" data-testid="trial-only"> {{ $options.i18n.trialOnly }} </span> </template> diff --git a/ee/app/assets/javascripts/usage_quotas/code_suggestions/components/add_on_eligible_user_list.vue b/ee/app/assets/javascripts/usage_quotas/code_suggestions/components/add_on_eligible_user_list.vue index 3ebc3ad38205c..2e6d77be22762 100644 --- a/ee/app/assets/javascripts/usage_quotas/code_suggestions/components/add_on_eligible_user_list.vue +++ b/ee/app/assets/javascripts/usage_quotas/code_suggestions/components/add_on_eligible_user_list.vue @@ -428,7 +428,7 @@ export default { v-else v-gl-tooltip :title="s__('Billing|An email address is only visible for users with public emails.')" - class="gl-font-style-italic" + class="gl-italic" > {{ s__('Billing|Private') }} </span> diff --git a/ee/app/assets/javascripts/usage_quotas/seats/components/subscription_user_list.vue b/ee/app/assets/javascripts/usage_quotas/seats/components/subscription_user_list.vue index e463cfd2fe92f..667449b942167 100644 --- a/ee/app/assets/javascripts/usage_quotas/seats/components/subscription_user_list.vue +++ b/ee/app/assets/javascripts/usage_quotas/seats/components/subscription_user_list.vue @@ -203,7 +203,7 @@ export default { v-else v-gl-tooltip :title="$options.i18n.emailNotVisibleTooltipText" - class="gl-font-style-italic" + class="gl-italic" > {{ s__('Billing|Private') }} </span> diff --git a/ee/app/assets/javascripts/vue_shared/security_reports/components/solution_card.vue b/ee/app/assets/javascripts/vue_shared/security_reports/components/solution_card.vue index 2a98ef09d8d38..4a65a6a3c0750 100644 --- a/ee/app/assets/javascripts/vue_shared/security_reports/components/solution_card.vue +++ b/ee/app/assets/javascripts/vue_shared/security_reports/components/solution_card.vue @@ -31,7 +31,7 @@ export default { <div> <h3>{{ s__('ciReport|Solution') }}</h3> <p ref="markdownContent" v-safe-html="solutionText" data-testid="solution-text"></p> - <p v-if="canDownloadPatch" class="gl-font-style-italic" data-testid="create-mr-message"> + <p v-if="canDownloadPatch" class="gl-italic" data-testid="create-mr-message"> {{ $options.i18n.createMergeRequestMsg }} </p> </div> diff --git a/ee/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_spec.js.snap b/ee/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_spec.js.snap index 9ce514f33762f..c83ddf01e4fa5 100644 --- a/ee/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_spec.js.snap +++ b/ee/spec/frontend/pages/projects/learn_gitlab/components/__snapshots__/learn_gitlab_spec.js.snap @@ -243,7 +243,7 @@ exports[`Learn GitLab Initial rendering concerns renders correctly 1`] = ` Add code owners </a> <span - class="gl-font-style-italic gl-text-gray-500" + class="gl-italic gl-text-gray-500" data-testid="trial-only" > - Included in trial @@ -270,7 +270,7 @@ exports[`Learn GitLab Initial rendering concerns renders correctly 1`] = ` Enable require merge approvals </a> <span - class="gl-font-style-italic gl-text-gray-500" + class="gl-italic gl-text-gray-500" data-testid="trial-only" > - Included in trial @@ -326,7 +326,7 @@ exports[`Learn GitLab Initial rendering concerns renders correctly 1`] = ` Scan dependencies for licenses </a> <span - class="gl-font-style-italic gl-text-gray-500" + class="gl-italic gl-text-gray-500" data-testid="trial-only" > - Included in trial @@ -353,7 +353,7 @@ exports[`Learn GitLab Initial rendering concerns renders correctly 1`] = ` Scan dependencies for vulnerabilities </a> <span - class="gl-font-style-italic gl-text-gray-500" + class="gl-italic gl-text-gray-500" data-testid="trial-only" > - Included in trial @@ -380,7 +380,7 @@ exports[`Learn GitLab Initial rendering concerns renders correctly 1`] = ` Analyze your application for vulnerabilities with DAST </a> <span - class="gl-font-style-italic gl-text-gray-500" + class="gl-italic gl-text-gray-500" data-testid="trial-only" > - Included in trial diff --git a/scripts/frontend/tailwind_all_the_way.mjs b/scripts/frontend/tailwind_all_the_way.mjs index 2c690ca7abccc..2267eb3285373 100755 --- a/scripts/frontend/tailwind_all_the_way.mjs +++ b/scripts/frontend/tailwind_all_the_way.mjs @@ -146,6 +146,11 @@ async function toMinimalUtilities() { // Disable all core plugins, all we care about are the legacy utils // that are provided via addUtilities. corePlugins: [], + // We must ensure the GitLab UI plugin is disabled during this run so that whatever it defines + // is purged out of the CSS-in-Js. + plugins: tailwindConfig.plugins.filter( + (plugin) => plugin.handler.name !== 'gitLabUIUtilities', + ), }), ]).process('@tailwind utilities;', { map: false, from: undefined }); @@ -215,9 +220,12 @@ export async function convertUtilsToCSSInJS({ buildOnlyUsed = false } = {}) { // We only want to generate the utils based on the fresh // allUtilitiesFile content: [allUtilitiesFile], - // We are disabling all plugins, so that the css-to-js - // import doesn't cause trouble. - plugins: [], + // We are disabling all plugins but the GitLab UI one which contains legitimate utils that + // will need to be backported to GitLab UI. + // This prevents the css-to-js import from causing trouble. + plugins: tailwindConfig.plugins.filter( + (plugin) => plugin.handler.name === 'gitLabUIUtilities', + ), }), ]).process('@tailwind utilities;', { map: false, from: undefined }); diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap index 5a6d84734a08f..043c80c0af42a 100644 --- a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap +++ b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/__snapshots__/project_empty_state_spec.js.snap @@ -38,7 +38,7 @@ exports[`Registry Project Empty state to match the default snapshot 1`] = ` value="" > <gl-form-input-stub - class="gl-font-monospace!" + class="!gl-font-monospace" readonly="" type="text" value="bazbaz" @@ -56,7 +56,7 @@ exports[`Registry Project Empty state to match the default snapshot 1`] = ` value="" > <gl-form-input-stub - class="gl-font-monospace!" + class="!gl-font-monospace" readonly="" type="text" value="foofoo" @@ -68,7 +68,7 @@ exports[`Registry Project Empty state to match the default snapshot 1`] = ` value="" > <gl-form-input-stub - class="gl-font-monospace!" + class="!gl-font-monospace" readonly="" type="text" value="barbar" diff --git a/spec/frontend/repository/components/commit_info_spec.js b/spec/frontend/repository/components/commit_info_spec.js index 78da409b0db8e..d9d268e0e67db 100644 --- a/spec/frontend/repository/components/commit_info_spec.js +++ b/spec/frontend/repository/components/commit_info_spec.js @@ -116,6 +116,6 @@ describe('Repository last commit component', () => { it('sets correct CSS class if the commit message is empty', () => { createComponent({ commitMock: { message: '' } }); - expect(findTitleHtml().classes()).toContain('gl-font-style-italic'); + expect(findTitleHtml().classes()).toContain('gl-italic'); }); }); -- GitLab