refactor(css): add prefix to component classes for consistency (#744)

* refactor(navbar): add hextra prefix to navbar and hamburger menu classes

- Updated CSS class names from `nav-container` to `hextra-nav-container` and `hamburger-menu` to `hextra-hamburger-menu` for improved clarity and consistency across the project.
- Adjusted related JavaScript and documentation to reflect the new class names.

* refactor(search): update class names for search components

- Renamed CSS classes from `search-wrapper`, `search-input`, `active`, `no-result`, `prefix`, `excerpt`, and `match` to `hextra-search-wrapper`, `hextra-search-input`, `hextra-search-active`, `hextra-search-no-result`, `hextra-search-prefix`, `hextra-search-excerpt`, and `hextra-search-match` for improved clarity and consistency.
- Updated JavaScript selectors to match the new class names, ensuring functionality remains intact.
- Adjusted HTML structure to reflect the new class naming convention.

* refactor(search): update search component class names for consistency

- Renamed existing search-related CSS classes to include the `hextra` prefix for improved clarity and consistency.
- Added optional nested classes for enhanced customization of the search UI, including titles, active states, and result snippets.
- Removed outdated breadcrumb section as no specific class is available.

* refactor(sidebar): rename sidebar classes for consistency

- Updated CSS and JavaScript to replace `sidebar-container` with `hextra-sidebar-container` and `sidebar-active-item` with `hextra-sidebar-active-item` for improved clarity and consistency across the project.
- Adjusted related documentation to reflect the new class names.

* refactor(language & theme): update class names for consistency

- Renamed language switcher and theme toggle classes to include the `hextra` prefix for improved clarity and consistency across the project.
- Updated related JavaScript selectors and documentation to reflect the new class names.

* refactor(css & html): rename classes for consistency and clarity

- Updated various CSS class names to include the `hextra` prefix, enhancing consistency across the project. This includes renaming classes such as `content` to `hextra-content`, `filename` to `hextra-code-filename`, and `steps` to `hextra-steps`.
- Adjusted related HTML and JavaScript to reflect the new class names, ensuring functionality and styling remain intact.
- Updated documentation to include the new class names for better clarity.

* refactor(language): update class names for language options

- Renamed the `language-options` class to `hextra-language-options` for consistency with the existing `hextra` prefix convention.
- Updated the corresponding HTML to reflect the new class name, ensuring clarity and uniformity across the project.

* refactor(css & html): rename classes for consistency and clarity

- Renamed CSS classes to include the `hextra` prefix, such as changing `subheading-anchor` to `hextra-subheading-anchor` and `footnotes` to `hextra-footnotes`, enhancing consistency across the project.
- Updated related HTML and documentation to reflect the new class names, ensuring clarity and uniformity.

* feat(typography): add styling for horizontal lines

- Introduced new styles for horizontal lines to enhance visual separation in content. The styles apply margin and border color adjustments, ensuring consistency with the overall design.

* feat(blog): add draft release announcement for Hextra v0.10.0

- Created a new markdown file for the draft release announcement of Hextra v0.10.0, including upgrade instructions and author details.
- The announcement is currently marked as a draft and may be updated before the official release.

* refactor(css & html): rename `hextra-content` class to `content` for consistency

- Updated the `hextra-content` class to simply `content` across various HTML files and CSS, enhancing clarity and consistency in the codebase.
- Adjusted the `package.json` script for the development server to include the `-F` flag for better functionality.

* refactor(typography & markdown): enhance table styling and markdown syntax

- Updated CSS for tables to improve styling, including adjustments to margins, borders, and text properties for better readability.
- Revised markdown documentation to standardize table formatting and improve clarity, including consistent syntax for headers and lists.
- Enhanced examples in the documentation to reflect the updated styling and ensure accurate representation of output.

* fix(blog): update text color for improved accessibility

- Modified the text color in the blog single layout to enhance readability in dark mode by adding a dark text color class.
- Ensured consistency in styling for better user experience across different themes.

* docs(blog): update draft release announcement for Hextra v0.10.0

- Revised the "What's New" section to include a TODO placeholder for future updates.
- Added a comprehensive migration guide detailing the CSS class prefix changes to enhance consistency and avoid conflicts.
- Updated the announcement to reflect the new class naming conventions for various components.

* chore: rebuild css
This commit is contained in:
Xin
2025-08-13 22:55:38 +08:00
committed by GitHub
parent 953042a0c0
commit 6823cc1fe8
30 changed files with 274 additions and 205 deletions

File diff suppressed because one or more lines are too long

View File

@@ -7,44 +7,44 @@ nav {
@supports (
(-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))
) {
.nav-container-blur {
.hextra-nav-container-blur {
@apply hx:backdrop-blur-md hx:bg-white/[.85] hx:dark:bg-dark/80!;
}
}
/* Hamburger Menu - Flattened Structure */
.hamburger-menu svg g {
.hextra-hamburger-menu svg g {
@apply hx:origin-center hx:transition-all hx:duration-100 hx:ease-out;
}
.hamburger-menu svg path {
.hextra-hamburger-menu svg path {
@apply hx:opacity-100 hx:transition-all hx:duration-100 hx:ease-out hx:delay-100;
}
.hamburger-menu svg.open path {
.hextra-hamburger-menu svg.open path {
@apply hx:transition-transform hx:duration-100 hx:ease-out hx:delay-0;
}
.hamburger-menu svg.open g {
.hextra-hamburger-menu svg.open g {
@apply hx:transition-transform hx:duration-100 hx:ease-out hx:delay-100;
}
.hamburger-menu svg.open > path {
.hextra-hamburger-menu svg.open > path {
@apply hx:opacity-0;
}
.hamburger-menu svg.open > g:nth-of-type(1) {
.hextra-hamburger-menu svg.open > g:nth-of-type(1) {
@apply hx:rotate-45;
}
.hamburger-menu svg.open > g:nth-of-type(1) path {
.hextra-hamburger-menu svg.open > g:nth-of-type(1) path {
@apply hx:translate-y-1;
}
.hamburger-menu svg.open > g:nth-of-type(2) {
.hextra-hamburger-menu svg.open > g:nth-of-type(2) {
@apply hx:-rotate-45;
}
.hamburger-menu svg.open > g:nth-of-type(2) path {
.hextra-hamburger-menu svg.open > g:nth-of-type(2) path {
@apply hx:-translate-y-1;
}

View File

@@ -1,30 +1,30 @@
.search-wrapper {
.hextra-search-wrapper {
li {
@apply hx:mx-2.5 hx:break-words hx:rounded-md hx:contrast-more:border hx:text-gray-800 hx:contrast-more:border-transparent hx:dark:text-gray-300;
a {
@apply hx:block hx:scroll-m-12 hx:px-2.5 hx:py-2;
}
.title {
.hextra-search-title {
@apply hx:text-base hx:font-semibold hx:leading-5;
}
.active {
.hextra-search-active {
@apply hx:rounded-md hx:bg-primary-500/10 hx:contrast-more:border-primary-500;
}
}
.no-result {
.hextra-search-no-result {
@apply hx:block hx:select-none hx:p-8 hx:text-center hx:text-sm hx:text-gray-400;
}
.prefix {
.hextra-search-prefix {
@apply hx:mx-2.5 hx:mb-2 hx:mt-6 hx:select-none hx:border-b hx:border-black/10 hx:px-2.5 hx:pb-1.5 hx:text-xs hx:font-semibold
hx:uppercase hx:text-gray-500 hx:first:mt-0 hx:dark:border-white/20 hx:dark:text-gray-300 hx:contrast-more:border-gray-600
hx:contrast-more:text-gray-900 hx:contrast-more:dark:border-gray-50 hx:contrast-more:dark:text-gray-50;
}
.excerpt {
.hextra-search-excerpt {
@apply hx:overflow-hidden hx:text-ellipsis hx:mt-1 hx:text-sm hx:leading-[1.35rem] hx:text-gray-600 hx:dark:text-gray-400 hx:contrast-more:dark:text-gray-50;
display: -webkit-box;
line-clamp: 1;
@@ -32,7 +32,7 @@
-webkit-box-orient: vertical;
}
.match {
.hextra-search-match {
@apply hx:text-primary-600;
}
}

View File

@@ -1,5 +1,5 @@
@media (max-width: 48rem) {
.sidebar-container {
.hextra-sidebar-container {
@apply hx:fixed hx:pt-[calc(var(--navbar-height))] hx:top-0 hx:w-full hx:bottom-0 hx:z-[15] hx:overscroll-contain hx:bg-white hx:dark:bg-dark;
transition: transform 0.4s cubic-bezier(0.52, 0.16, 0.04, 1);
will-change: transform, opacity;
@@ -8,7 +8,7 @@
}
}
.sidebar-container {
.hextra-sidebar-container {
li > div {
@apply hx:h-0;
}

View File

@@ -1,4 +1,4 @@
.steps {
.hextra-steps {
:where(h2, h3, h4, h5, h6):not(.no-step-marker) {
counter-increment: step;
@apply hx:ltr:before:ml-[-41px] hx:rtl:before:mr-[-44px];
@@ -13,7 +13,7 @@
}
}
:lang(fa) .steps {
:lang(fa) .hextra-steps {
:where(h2, h3, h4, h5, h6):not(.no-step-marker) {
&:before {
content: counter(step, persian);

View File

@@ -9,11 +9,11 @@
@apply hx:text-[.9em] hx:bg-primary-700/5 hx:overflow-x-auto hx:font-medium hx:subpixel-antialiased hx:dark:bg-primary-300/10 hx:contrast-more:border hx:contrast-more:border-primary-900/20 hx:contrast-more:contrast-150 hx:contrast-more:dark:border-primary-100/40;
}
.filename {
.hextra-code-filename {
@apply hx:absolute hx:top-0 hx:z-[1] hx:w-full hx:truncate hx:rounded-t-xl hx:bg-primary-700/5 hx:py-2 hx:px-4 hx:text-xs hx:text-gray-700 hx:dark:bg-primary-300/10 hx:dark:text-gray-200;
}
.filename + pre:not(.lntable pre) {
.hextra-code-filename + pre:not(.lntable pre) {
/* Override padding for code blocks with filename but no highlight */
@apply hx:pt-12;
}

View File

@@ -33,16 +33,19 @@
@apply hx:border-black/4 hx:bg-black/3 hx:break-words hx:rounded-md hx:border hx:py-0.5 hx:px-[.25em] hx:text-[.9em] hx:dark:border-white/10 hx:dark:bg-white/10;
}
:where(table):not(:where(.hextra-code-block table, [class~=not-prose],[class~=not-prose] *)) {
@apply hx:block hx:overflow-x-auto hx:mt-6 hx:p-0 hx:first:mt-0;
@apply hx:block hx:overflow-x-auto hx:my-6 hx:p-0 hx:first:mt-0 hx:w-full hx:text-sm hx:leading-5;
tr {
@apply hx:m-0 hx:border-t hx:border-gray-300 hx:p-0 hx:dark:border-gray-600 hx:even:bg-gray-100 hx:even:dark:bg-gray-600/20;
thead {
@apply hx:border-b hx:border-gray-200 hx:dark:border-neutral-800;
}
tbody tr {
@apply hx:m-0 hx:border-b hx:border-gray-100 hx:dark:border-neutral-800/50;
}
th {
@apply hx:m-0 hx:border hx:border-gray-300 hx:px-4 hx:py-2 hx:font-semibold hx:dark:border-gray-600;
@apply hx:m-0 hx:p-2 hx:font-semibold hx:first:pl-0 hx:last:pr-0;
}
td {
@apply hx:m-0 hx:border hx:border-gray-300 hx:px-4 hx:py-2 hx:dark:border-gray-600;
@apply hx:m-0 hx:p-2 hx:first:pl-0 hx:last:pr-0;
}
}
:where(ol):not(:where([class~=not-prose],[class~=not-prose] *)) {
@@ -86,6 +89,10 @@
@apply hx:my-2 hx:ps-6;
}
}
/* Horizontal line */
:where(hr):not(:where([class~=not-prose],[class~=not-prose] *)) {
@apply hx:my-10 hx:first:mt-0 hx:last:mb-0 hx:border-gray-200 hx:dark:border-neutral-800;
}
.footnotes {
@apply hx:mt-12 hx:text-sm;
@@ -93,28 +100,27 @@
@apply hx:border-gray-200 hx:dark:border-neutral-800;
}
}
}
.subheading-anchor {
@apply hx:opacity-0 hx:transition-opacity hx:ltr:ml-1 hx:rtl:mr-1;
span:target + &,
:hover > &,
&:focus {
@apply hx:opacity-100;
}
span + &,
:hover > & {
@apply hx:no-underline!;
}
@apply hx:after:text-gray-300 hx:dark:after:text-neutral-700;
&:after {
@apply hx:content-['#'] hx:px-1;
span:target + & {
@apply hx:text-gray-400;
@apply hx:dark:text-neutral-500;
.subheading-anchor {
@apply hx:opacity-0 hx:transition-opacity hx:ltr:ml-1 hx:rtl:mr-1;
span:target + &,
:hover > &,
&:focus {
@apply hx:opacity-100;
}
span + &,
:hover > & {
@apply hx:no-underline!;
}
@apply hx:after:text-gray-300 hx:dark:after:text-neutral-700;
&:after {
@apply hx:content-['#'] hx:px-1;
span:target + & {
@apply hx:text-gray-400;
@apply hx:dark:text-neutral-500;
}
}
}
}

View File

@@ -27,8 +27,8 @@ document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.hextra-code-copy-btn').forEach(function (button) {
// Add copy and success icons
button.querySelector('.copy-icon')?.appendChild(getCopyIcon());
button.querySelector('.success-icon')?.appendChild(getSuccessIcon());
button.querySelector('.hextra-copy-icon')?.appendChild(getCopyIcon());
button.querySelector('.hextra-success-icon')?.appendChild(getSuccessIcon());
// Add click event listener for copy button
button.addEventListener('click', function (e) {

View File

@@ -3,8 +3,8 @@
// Change shortcut key to cmd+k on Mac, iPad or iPhone.
document.addEventListener("DOMContentLoaded", function () {
if (/iPad|iPhone|Macintosh/.test(navigator.userAgent)) {
// select the kbd element under the .search-wrapper class
const keys = document.querySelectorAll(".search-wrapper kbd");
// select the kbd element under the .hextra-search-wrapper class
const keys = document.querySelectorAll(".hextra-search-wrapper kbd");
keys.forEach(key => {
key.innerHTML = '<span class="hx:text-xs">⌘</span>K';
});
@@ -22,7 +22,7 @@ document.addEventListener("DOMContentLoaded", function () {
(function () {
const searchDataURL = '{{ $searchData.RelPermalink }}';
const inputElements = document.querySelectorAll('.search-input');
const inputElements = document.querySelectorAll('.hextra-search-input');
for (const el of inputElements) {
el.addEventListener('focus', init);
el.addEventListener('keyup', search);
@@ -30,7 +30,7 @@ document.addEventListener("DOMContentLoaded", function () {
el.addEventListener('input', handleInputChange);
}
const shortcutElements = document.querySelectorAll('.search-wrapper kbd');
const shortcutElements = document.querySelectorAll('.hextra-search-wrapper kbd');
function setShortcutElementsOpacity(opacity) {
shortcutElements.forEach(el => {
@@ -45,12 +45,12 @@ document.addEventListener("DOMContentLoaded", function () {
// Get the search wrapper, input, and results elements.
function getActiveSearchElement() {
const inputs = Array.from(document.querySelectorAll('.search-wrapper')).filter(el => el.clientHeight > 0);
const inputs = Array.from(document.querySelectorAll('.hextra-search-wrapper')).filter(el => el.clientHeight > 0);
if (inputs.length === 1) {
return {
wrapper: inputs[0],
inputElement: inputs[0].querySelector('.search-input'),
resultsElement: inputs[0].querySelector('.search-results')
inputElement: inputs[0].querySelector('.hextra-search-input'),
resultsElement: inputs[0].querySelector('.hextra-search-results')
};
}
return undefined;
@@ -103,7 +103,7 @@ document.addEventListener("DOMContentLoaded", function () {
const { resultsElement } = getActiveSearchElement();
if (!resultsElement) return { result: undefined, index: -1 };
const result = resultsElement.querySelector('.active');
const result = resultsElement.querySelector('.hextra-search-active');
if (!result) return { result: undefined, index: -1 };
const index = parseInt(result.dataset.index, 10);
@@ -116,10 +116,10 @@ document.addEventListener("DOMContentLoaded", function () {
if (!resultsElement) return;
const { result: activeResult } = getActiveResult();
activeResult && activeResult.classList.remove('active');
activeResult && activeResult.classList.remove('hextra-search-active');
const result = resultsElement.querySelector(`[data-index="${index}"]`);
if (result) {
result.classList.add('active');
result.classList.add('hextra-search-active');
result.focus();
}
}
@@ -384,7 +384,7 @@ document.addEventListener("DOMContentLoaded", function () {
if (!resultsElement) return;
if (!results.length) {
resultsElement.innerHTML = `<span class="no-result">{{ $noResultsFound | safeHTML }}</span>`;
resultsElement.innerHTML = `<span class="hextra-search-no-result">{{ $noResultsFound | safeHTML }}</span>`;
return;
}
@@ -418,14 +418,14 @@ document.addEventListener("DOMContentLoaded", function () {
const result = results[i];
if (result.prefix) {
fragment.appendChild(createElement(`
<div class="prefix">${result.prefix}</div>`));
<div class="hextra-search-prefix">${result.prefix}</div>`));
}
let li = createElement(`
let li = createElement(`
<li>
<a data-index="${i}" href="${result.route}" class=${i === 0 ? "active" : ""}>
<div class="title">`+ highlightMatches(result.children.title, query) + `</div>` +
<a data-index="${i}" href="${result.route}" class=${i === 0 ? "hextra-search-active" : ""}>
<div class="hextra-search-title">`+ highlightMatches(result.children.title, query) + `</div>` +
(result.children.content ?
`<div class="excerpt">` + highlightMatches(result.children.content, query) + `</div>` : '') + `
`<div class="hextra-search-excerpt">` + highlightMatches(result.children.content, query) + `</div>` : '') + `
</a>
</li>`);
li.addEventListener('mousemove', handleMouseMove);

View File

@@ -1,5 +1,5 @@
(function () {
const languageSwitchers = document.querySelectorAll('.language-switcher');
const languageSwitchers = document.querySelectorAll('.hextra-language-switcher');
languageSwitchers.forEach((switcher) => {
switcher.addEventListener('click', (e) => {
e.preventDefault();
@@ -17,7 +17,7 @@
// Dismiss language switcher when clicking outside
document.addEventListener('click', (e) => {
if (e.target.closest('.language-switcher') === null) {
if (e.target.closest('.hextra-language-switcher') === null) {
languageSwitchers.forEach((switcher) => {
switcher.dataset.state = 'closed';
const optionsElement = switcher.nextElementSibling;

View File

@@ -1,8 +1,8 @@
// Hamburger menu for mobile navigation
document.addEventListener('DOMContentLoaded', function () {
const menu = document.querySelector('.hamburger-menu');
const sidebarContainer = document.querySelector('.sidebar-container');
const menu = document.querySelector('.hextra-hamburger-menu');
const sidebarContainer = document.querySelector('.hextra-sidebar-container');
function toggleMenu() {
// Toggle the hamburger menu

View File

@@ -17,8 +17,8 @@ function enableCollapsibles() {
}
function scrollToActiveItem() {
const sidebarScrollbar = document.querySelector("aside.sidebar-container > .hextra-scrollbar");
const activeItems = document.querySelectorAll(".sidebar-active-item");
const sidebarScrollbar = document.querySelector("aside.hextra-sidebar-container > .hextra-scrollbar");
const activeItems = document.querySelectorAll(".hextra-sidebar-active-item");
const visibleActiveItem = Array.from(activeItems).find(function (activeItem) {
return activeItem.getBoundingClientRect().height > 0;
});

View File

@@ -2,7 +2,7 @@
(function () {
const defaultTheme = '{{ site.Params.theme.default | default `system`}}'
const themeToggleButtons = document.querySelectorAll(".theme-toggle");
const themeToggleButtons = document.querySelectorAll(".hextra-theme-toggle");
// Change the icons of the buttons based on previous settings or system theme
if (