-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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(layout): Semantic html tags #1626
base: v4
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first pass, but still have few items up for discussion
232944a
to
1e182ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second pass. cc @saberzero1 @jackyzha0
Actually, sorry I might be wrong about section here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section Seems like section should always followed with a heading -> p, so section for each sidebar or container doesn't make sense afaict |
Sections should be used for parts of a text. Basically every part that the Table of Contents component identifies. I also believe we should use aside for the sidebars, not section. Additionally, we should consider the search tag for the Search component. |
@aarnphm @saberzero1 I made a breaking changes in b2423a3, are we ok with it? |
b2423a3
to
81e943b
Compare
yea, we might want to bump the version to v4.5 or sth to signify breakage |
@@ -18,7 +18,7 @@ export default ((userOpts?: Partial<SearchOptions>) => { | |||
const opts = { ...defaultOptions, ...userOpts } | |||
const searchPlaceholder = i18n(cfg.locale).components.search.searchBarPlaceholder | |||
return ( | |||
<div class={classNames(displayClass, "search")}> | |||
<search class={classNames(displayClass, "search")}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default container should be div, and diff search-container to tag
<search id="search-container">
<form id="search-space">
<input
autocomplete="off"
id="search-bar"
name="search"
type="text"
aria-label={searchPlaceholder}
placeholder={searchPlaceholder}
/>
</form>
<output id="search-layout" data-preview={opts.enablePreview}></output>
</search>
might have to update scss as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example demonstrates potential DOM content when dynamically including JavaScript search functionality in a web application. When search functionality is implemented entirely with JavaScript, if no form is submitted, neither a
element nor a submit is required. For semantics, the element is included to contain the search and filtering capabilities.
(c) https://developer.mozilla.org/en-US/docs/Web/HTML/Element/search#web_app_search
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg, can you then also update the search-container to section and output and form accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, you have a js search and no form. MDN specifies for such case, that form does not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The element semantically identifies the purpose of the element's contents as having search or filtering capabilities. The search or filtering functionality can be for the website or application, the current web page or document, or the entire Internet or subsection thereof.
From their example
<search>
<label>
Find and filter your query
<input type="search" id="query" />
</label>
<label>
<input type="checkbox" id="exact-only" />
Exact matches only
</label>
<section>
<h3>Results:</h3>
<ul id="results">
<!-- search result content -->
</ul>
<output id="no-results">
<!-- no results content -->
</output>
</section>
</search>
Ig we don't need form, but for the layout seems to align with their example
quartz/components/Body.tsx
Outdated
@@ -4,7 +4,7 @@ import clipboardStyle from "./styles/clipboard.scss" | |||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" | |||
|
|||
const Body: QuartzComponent = ({ children }: QuartzComponentProps) => { | |||
return <div id="quartz-body">{children}</div> | |||
return <main id="quartz-body">{children}</main> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think main should be for quartz-root
, and this can be either a section or a div
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
The content inside the
element should be unique to the document. It should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms.
So I have place it around Content.
* aside --> section * header --> header + pageHeader
* move Explorer to menu * move Search to search * move sidebars to aside
* make header above all content * make beforeBody --> pageHeader
4e8ee98
to
e525f85
Compare
@@ -27,5 +27,5 @@ export function formatDate(d: Date, locale: ValidLocale = "en-US"): string { | |||
} | |||
|
|||
export function Date({ date, locale }: Props) { | |||
return <time datetime={date.toISOString()}>{formatDate(date, locale)}</time> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad merge
@@ -18,7 +18,7 @@ export default ((userOpts?: Partial<SearchOptions>) => { | |||
const opts = { ...defaultOptions, ...userOpts } | |||
const searchPlaceholder = i18n(cfg.locale).components.search.searchBarPlaceholder | |||
return ( | |||
<div class={classNames(displayClass, "search")}> | |||
<search class={classNames(displayClass, "search")}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The element semantically identifies the purpose of the element's contents as having search or filtering capabilities. The search or filtering functionality can be for the website or application, the current web page or document, or the entire Internet or subsection thereof.
From their example
<search>
<label>
Find and filter your query
<input type="search" id="query" />
</label>
<label>
<input type="checkbox" id="exact-only" />
Exact matches only
</label>
<section>
<h3>Results:</h3>
<ul id="results">
<!-- search result content -->
</ul>
<output id="no-results">
<!-- no results content -->
</output>
</section>
</search>
Ig we don't need form, but for the layout seems to align with their example
<div class="popover-hint"> | ||
{beforeBody.map((BodyComponent) => ( | ||
<BodyComponent {...componentData} /> | ||
))} | ||
</div> | ||
</div> | ||
<Content {...componentData} /> | ||
<main> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just keep content as article as before wrapping main here is redudant.
The
<article>
HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication). Examples include: a forum post, a magazine or newspaper article, or a blog entry, a product card, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
The
<main>
HTML element represents the dominant content of the of a document. The main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application.
In this case article represents the content translated from the markdown, and main encapsulate Body
component
Implemented comment from #1588 (comment).