सुलभता पैटर्न · संवाद
टिप्पणी थ्रेड
हर टिप्पणी अपने लेखक के नाम वाला एक आर्टिकल है, और जवाब उस टिप्पणी के अंदर नेस्टेड सूची हैं जिसका वे जवाब देते हैं, इसलिए थ्रेड का आकार मार्कअप में है। जवाब, एडिट और डिलीट अपनी जगह पर खुलते हैं और फ़ोकस लेते हैं; Escape फ़ोकस को उसी बटन पर लौटाता है जिसने उन्हें खोला, और हर बदलाव की पुष्टि एक विनम्र स्टेटस में होती है।
- डब्ल्यूसीएजी मानदंड
- 7
- कीबोर्ड नियम
- 4
- जाँच का तरीक़ा
- axe, कीबोर्ड और इंस्पेक्टर
लाइव डेमो
आज़माएँ
इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।
जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।
कीबोर्ड
जिन कुंजियों पर यह काम करता है
हर क्रिया पॉइंटर के बिना काम करती है।
| कुंजी | यह क्या करती है |
|---|---|
| TabयाShiftTab | टिप्पणी बॉक्स, हर टिप्पणी के बटनों और थ्रेड टॉगल से पढ़ने के क्रम में गुज़रता है। |
| EnterयाSpace | जवाब दें पर, उस टिप्पणी के नीचे जवाब बॉक्स खोलता है और फ़ोकस उसमें ले जाता है। थ्रेड टॉगल पर, उसके जवाब छिपाता या दिखाता है। |
| Escape | जवाब बॉक्स, एडिट बॉक्स या डिलीट वाले सवाल में, उसे बंद करता है और फ़ोकस उसी बटन पर लौटाता है जिसने उसे खोला। |
| Enter | टिप्पणी पोस्ट करें या जवाब पोस्ट करें पर, उसे पोस्ट करता है और फ़ोकस नई टिप्पणी पर ले जाता है। सहेजें पर, बदलाव रखता है और फ़ोकस एडिट पर लौटाता है। |
स्क्रीन रीडर
यह क्या घोषित करता है
मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।
| कब | अपेक्षित घोषणा |
|---|---|
| Tab किसी जवाब दें बटन पर पहुँचता है | आशा को जवाब दें, बटन, संक्षिप्त |
| Enter जवाब बॉक्स खोलता है | आशा को जवाब दें, संपादन बॉक्स, बहु-पंक्ति |
| जवाब पोस्ट होता है | आप, आर्टिकल (फ़ोकस नए जवाब पर), फिर: जवाब पोस्ट हुआ |
| फ़ोकस किसी थ्रेड टॉगल पर पहुँचता है | 3 जवाब छिपाएँ, बटन, विस्तारित |
| आपकी टिप्पणी पर डिलीट दबाया जाता है | यह टिप्पणी डिलीट करें? इसे पहले जैसा नहीं किया जा सकता। समूह। रद्द, बटन |
| एक टिप्पणी पोस्ट होती है | आप, आर्टिकल, फिर: टिप्पणी पोस्ट हुई |
ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।
कोड
कोड कॉपी करें
वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।
<section class="ap-comments" data-ap-comments aria-labelledby="cmt-h">
<div class="ap-comments__head">
<h3 class="ap-comments__count" id="cmt-h" tabindex="-1">Comments <span class="ap-comments__n" data-ap-cmt-total>6</span></h3>
<p class="ap-comments__status" role="status"></p>
</div>
<form class="ap-comments__new" data-ap-cmt-new data-max="500" novalidate>
<label class="ap-label" for="cmt-new-text">Add a comment</label>
<textarea class="ap-input" id="cmt-new-text" name="comment" rows="3" aria-describedby="cmt-new-count"></textarea>
<p class="ap-error" id="cmt-new-error" hidden><svg class="ap-comments__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5"/><path d="M12 16.5h.01"/></svg><span></span></p>
<div class="ap-comments__bar">
<p class="ap-comments__left" id="cmt-new-count"><span data-ap-cmt-left>500</span> <span data-ap-cmt-words>characters left</span></p>
<button type="submit" class="ap-btn ap-btn--primary">Post comment</button>
</div>
</form>
<ol class="ap-comments__list">
<li>
<article class="ap-comments__c" id="cmt-1" aria-labelledby="cmt-1-who" tabindex="-1">
<span class="ap-comments__avatar" aria-hidden="true" translate="no">AR</span>
<div class="ap-comments__main">
<p class="ap-comments__meta"><span class="ap-comments__who" id="cmt-1-who">Asha Rao</span> <time datetime="2026-10-05T09:12+05:30" title="5 October 2026 at 09:12">3 hours ago<span class="ap-comments__vh">, <span>5 October 2026 at 09:12</span></span></time></p>
<p class="ap-comments__text">Carry two pairs of socks. The trail turns into a stream after Udhewadi, and wet feet blister fast.</p>
<div class="ap-comments__acts">
<button type="button" class="ap-comments__act" data-ap-cmt-reply aria-label="Reply to Asha" aria-expanded="false"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v4"/></svg>Reply</button>
</div>
</div>
</article>
<button type="button" class="ap-comments__toggle" data-ap-cmt-toggle aria-expanded="true" aria-controls="cmt-1-replies"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m6 9 6 6 6-6"/></svg><span>Hide 3 replies</span></button>
<ol class="ap-comments__replies" id="cmt-1-replies">
<li>
<article class="ap-comments__c" id="cmt-1a" aria-labelledby="cmt-1a-who" tabindex="-1">
<span class="ap-comments__avatar" aria-hidden="true" translate="no">VS</span>
<div class="ap-comments__main">
<p class="ap-comments__meta"><span class="ap-comments__who" id="cmt-1a-who">Vikram Shetty</span> <time datetime="2026-10-05T10:05+05:30" title="5 October 2026 at 10:05">2 hours ago<span class="ap-comments__vh">, <span>5 October 2026 at 10:05</span></span></time></p>
<p class="ap-comments__text">Seconded. Quick-dry socks were worth every rupee.</p>
<div class="ap-comments__acts">
<button type="button" class="ap-comments__act" data-ap-cmt-reply aria-label="Reply to Vikram" aria-expanded="false"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v4"/></svg>Reply</button>
</div>
</div>
</article>
</li>
<li>
<article class="ap-comments__c" id="cmt-1b" aria-labelledby="cmt-1b-who" tabindex="-1">
<span class="ap-comments__avatar" aria-hidden="true" translate="no">NK</span>
<div class="ap-comments__main">
<p class="ap-comments__meta"><span class="ap-comments__who" id="cmt-1b-who">Neha Kulkarni</span> <time datetime="2026-10-05T10:31+05:30" title="5 October 2026 at 10:31">2 hours ago<span class="ap-comments__vh">, <span>5 October 2026 at 10:31</span></span></time></p>
<p class="ap-comments__text">Is the path marked, or do we need a guide from Lonavala?</p>
<div class="ap-comments__acts">
<button type="button" class="ap-comments__act" data-ap-cmt-reply aria-label="Reply to Neha" aria-expanded="false"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v4"/></svg>Reply</button>
</div>
</div>
</article>
</li>
<li>
<article class="ap-comments__c" id="cmt-1c" aria-labelledby="cmt-1c-who" tabindex="-1" data-own>
<span class="ap-comments__avatar ap-comments__avatar--me" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false"><circle cx="12" cy="8.5" r="3.5"/><path d="M5 20a7 7 0 0 1 14 0"/></svg></span>
<div class="ap-comments__main">
<p class="ap-comments__meta"><span class="ap-comments__who" id="cmt-1c-who">You</span> <time datetime="2026-10-05T11:02+05:30" title="5 October 2026 at 11:02">1 hour ago<span class="ap-comments__vh">, <span>5 October 2026 at 11:02</span></span></time></p>
<p class="ap-comments__text">It's marked up to the village. After that, follow the fort walls.</p>
<div class="ap-comments__acts">
<button type="button" class="ap-comments__act" data-ap-cmt-edit aria-label="Edit your comment"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>Edit</button>
<button type="button" class="ap-comments__act" data-ap-cmt-delete aria-label="Delete your comment"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="M6 7l1 13h10l1-13"/><path d="M9 7V4h6v3"/></svg>Delete</button>
</div>
</div>
</article>
</li>
</ol>
</li>
<li>
<article class="ap-comments__c" id="cmt-2" aria-labelledby="cmt-2-who" tabindex="-1">
<span class="ap-comments__avatar" aria-hidden="true" translate="no">RM</span>
<div class="ap-comments__main">
<p class="ap-comments__meta"><span class="ap-comments__who" id="cmt-2-who">Rohan Mehta</span> <time datetime="2026-10-04T18:40+05:30" title="4 October 2026 at 18:40">17 hours ago<span class="ap-comments__vh">, <span>4 October 2026 at 18:40</span></span></time></p>
<p class="ap-comments__text">Start before 7. The last shared jeeps back to Lonavala leave by 5.</p>
<div class="ap-comments__acts">
<button type="button" class="ap-comments__act" data-ap-cmt-reply aria-label="Reply to Rohan" aria-expanded="false"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v4"/></svg>Reply</button>
</div>
</div>
</article>
<button type="button" class="ap-comments__toggle" data-ap-cmt-toggle aria-expanded="false" aria-controls="cmt-2-replies"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m6 9 6 6 6-6"/></svg><span>Show 1 reply</span></button>
<ol class="ap-comments__replies" id="cmt-2-replies" hidden>
<li>
<article class="ap-comments__c" id="cmt-2a" aria-labelledby="cmt-2a-who" tabindex="-1">
<span class="ap-comments__avatar" aria-hidden="true" translate="no">AR</span>
<div class="ap-comments__main">
<p class="ap-comments__meta"><span class="ap-comments__who" id="cmt-2a-who">Asha Rao</span> <time datetime="2026-10-04T19:15+05:30" title="4 October 2026 at 19:15">16 hours ago<span class="ap-comments__vh">, <span>4 October 2026 at 19:15</span></span></time></p>
<p class="ap-comments__text">And carry cash. The village stalls can't take UPI when the network drops.</p>
<div class="ap-comments__acts">
<button type="button" class="ap-comments__act" data-ap-cmt-reply aria-label="Reply to Asha" aria-expanded="false"><svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 0 1 6 6v4"/></svg>Reply</button>
</div>
</div>
</article>
</li>
</ol>
</li>
</ol>
<div class="ap-comments__spare">
<form class="ap-comments__form" id="cmt-replyform" data-ap-cmt-replyform novalidate hidden>
<label class="ap-label" for="cmt-reply-text" data-ap-cmt-replylabel>Reply</label>
<textarea class="ap-input" id="cmt-reply-text" name="reply" rows="2"></textarea>
<p class="ap-error" id="cmt-reply-error" hidden><svg class="ap-comments__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5"/><path d="M12 16.5h.01"/></svg><span>Write a reply first.</span></p>
<div class="ap-comments__btns">
<button type="button" class="ap-btn" data-ap-cmt-cancel>Cancel</button>
<button type="submit" class="ap-btn ap-btn--primary">Post reply</button>
</div>
</form>
<form class="ap-comments__form" id="cmt-editform" data-ap-cmt-editform novalidate hidden>
<label class="ap-label" for="cmt-edit-text">Edit your comment</label>
<textarea class="ap-input" id="cmt-edit-text" name="edit" rows="2"></textarea>
<p class="ap-error" id="cmt-edit-error" hidden><svg class="ap-comments__icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5"/><path d="M12 16.5h.01"/></svg><span>Write something, or delete the comment instead.</span></p>
<div class="ap-comments__btns">
<button type="button" class="ap-btn" data-ap-cmt-cancel>Cancel</button>
<button type="submit" class="ap-btn ap-btn--primary">Save</button>
</div>
</form>
<div class="ap-comments__confirm" role="group" aria-labelledby="cmt-confirm-q" data-ap-cmt-confirm hidden>
<p class="ap-comments__q" id="cmt-confirm-q">Delete this comment? This cannot be undone.</p>
<div class="ap-comments__btns">
<button type="button" class="ap-btn" data-ap-cmt-keep>Cancel</button>
<button type="button" class="ap-btn ap-btn--danger" data-ap-cmt-remove>Delete</button>
</div>
</div>
</div>
<p class="ap-comments__vh" aria-live="polite" data-ap-cmt-say></p>
</section>
/* Shared primitives: buttons and form fields used across the patterns.
Uses the --ap-* design tokens. */
.ap-btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
min-height: 40px;
padding: 0 16px;
border: 1px solid var(--ap-border-strong);
border-radius: var(--ap-radius-sm);
background: var(--ap-surface);
color: var(--ap-text);
font: inherit;
font-weight: 600;
line-height: 1.2;
text-decoration: none;
white-space: nowrap;
cursor: pointer;
transition: background-color var(--ap-duration) var(--ap-ease), border-color var(--ap-duration) var(--ap-ease), box-shadow var(--ap-duration) var(--ap-ease);
}
.ap-btn:hover {
background: var(--ap-surface-2);
}
.ap-btn:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 2px;
}
.ap-btn:disabled,
.ap-btn[aria-disabled="true"] {
opacity: .55;
cursor: not-allowed;
}
.ap-btn--primary {
border-color: var(--ap-accent);
background: var(--ap-accent);
color: var(--ap-on-accent);
box-shadow: var(--ap-shadow-sm);
}
.ap-btn--primary:hover {
border-color: var(--ap-accent-hover);
background: var(--ap-accent-hover);
}
.ap-btn--danger {
border-color: var(--ap-danger);
background: var(--ap-danger);
color: var(--ap-surface);
}
.ap-btn--danger:hover {
filter: brightness(1.08);
}
.ap-btn--ghost {
border-color: transparent;
background: transparent;
}
.ap-btn--ghost:hover {
background: var(--ap-surface-2);
}
.ap-btn__icon {
width: 18px;
height: 18px;
flex-shrink: 0;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.ap-field {
display: grid;
gap: 6px;
}
.ap-label {
color: var(--ap-text);
font-weight: 600;
font-size: .9375rem;
}
.ap-hint {
margin: 0;
color: var(--ap-text-3);
font-size: .875rem;
line-height: 1.45;
}
.ap-error {
display: flex;
align-items: flex-start;
gap: 6px;
margin: 0;
color: var(--ap-danger);
font-size: .875rem;
font-weight: 600;
line-height: 1.45;
}
.ap-input {
width: 100%;
min-height: 44px;
padding: 10px 12px;
border: 1px solid var(--ap-border-strong);
border-radius: var(--ap-radius-sm);
background: var(--ap-surface);
color: var(--ap-text);
font: inherit;
line-height: 1.4;
transition: border-color var(--ap-duration) var(--ap-ease), box-shadow var(--ap-duration) var(--ap-ease);
}
.ap-input::placeholder {
color: var(--ap-text-3);
}
.ap-input:hover {
border-color: var(--ap-text-2);
}
.ap-input:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 1px;
border-color: var(--ap-focus);
}
.ap-input[aria-invalid="true"] {
border-color: var(--ap-danger);
box-shadow: inset 4px 0 0 var(--ap-danger);
}
textarea.ap-input {
resize: vertical;
min-height: 88px;
}
@media (prefers-reduced-motion: reduce) {
.ap-btn,
.ap-input { transition: none; }
}
/* Comment thread. Uses the --ap-* design tokens and the shared primitives. */
.ap-comments {
width: min(100%, 600px);
margin-inline: auto;
padding: 22px 24px 26px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius-lg);
background: var(--ap-surface);
color: var(--ap-text);
box-shadow: var(--ap-shadow-md);
container-type: inline-size;
}
.ap-comments [hidden] {
display: none !important;
}
/* Heading, count and the outcome of the last action */
.ap-comments__head {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 6px 16px;
}
.ap-comments__count {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
font-size: 1.125rem;
font-weight: 650;
line-height: 1.3;
}
.ap-comments__count:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 4px;
border-radius: 4px;
}
.ap-comments__n {
min-width: 26px;
padding: 1px 8px;
border-radius: var(--ap-radius-full);
background: var(--ap-surface-2);
color: var(--ap-text-2);
font-size: .8125rem;
font-weight: 650;
text-align: center;
font-variant-numeric: tabular-nums;
}
.ap-comments__status {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
color: var(--ap-success);
font-size: .875rem;
font-weight: 600;
}
.ap-comments__status:not(:empty)::before {
content: "";
width: 10px;
height: 5px;
margin-top: -3px;
border-bottom: 2px solid currentColor;
border-left: 2px solid currentColor;
transform: rotate(-45deg);
}
/* The new comment box */
.ap-comments__new {
display: grid;
gap: 6px;
margin-top: 16px;
padding-bottom: 22px;
border-bottom: 1px solid var(--ap-border);
}
.ap-comments__bar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 4px;
}
.ap-comments__left {
margin: 0;
color: var(--ap-text-3);
font-size: .8125rem;
}
.ap-comments__left [data-ap-cmt-left] {
color: var(--ap-text-2);
font-weight: 650;
font-variant-numeric: tabular-nums;
}
.ap-comments__left[data-over],
.ap-comments__left[data-over] [data-ap-cmt-left] {
color: var(--ap-danger);
font-weight: 650;
}
.ap-comments__icon {
flex-shrink: 0;
width: 18px;
height: 18px;
margin-top: 1px;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
}
/* Comments and replies */
.ap-comments__list,
.ap-comments__replies {
margin: 0;
padding: 0;
list-style: none;
}
.ap-comments__list > li {
padding-top: 18px;
}
.ap-comments__list > li + li {
margin-top: 18px;
border-top: 1px solid var(--ap-border);
}
.ap-comments__replies {
display: grid;
gap: 14px;
margin: 6px 0 0 19px;
padding: 8px 0 2px 25px;
border-left: 2px solid var(--ap-border);
}
.ap-comments__c {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
gap: 12px;
border-radius: var(--ap-radius-sm);
}
.ap-comments__c:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 6px;
}
.ap-comments__avatar {
display: grid;
place-items: center;
width: 40px;
height: 40px;
border-radius: var(--ap-radius-full);
background: var(--ap-surface-3);
color: var(--ap-text);
font-size: .8125rem;
font-weight: 700;
letter-spacing: .02em;
}
.ap-comments__replies .ap-comments__avatar {
width: 32px;
height: 32px;
font-size: .75rem;
}
.ap-comments__avatar--me {
background: var(--ap-accent-soft);
color: var(--ap-accent-soft-text);
}
.ap-comments__avatar svg {
width: 55%;
height: 55%;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
}
.ap-comments__main {
min-width: 0;
}
.ap-comments__meta {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 2px 8px;
margin: 0;
color: var(--ap-text-3);
font-size: .8125rem;
}
.ap-comments__who {
color: var(--ap-text);
font-size: .9375rem;
font-weight: 650;
}
.ap-comments__edited {
padding: 0 6px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius-full);
font-size: .75rem;
}
.ap-comments__text {
margin: 4px 0 0;
color: var(--ap-text-2);
line-height: 1.55;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
/* Reply, Edit and Delete */
.ap-comments__acts {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin: 6px 0 0 -8px;
}
.ap-comments__act,
.ap-comments__toggle {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 32px;
padding: 0 8px;
border: 0;
border-radius: var(--ap-radius-sm);
background: transparent;
color: var(--ap-text-2);
font: inherit;
font-size: .875rem;
font-weight: 600;
cursor: pointer;
}
.ap-comments__act:hover,
.ap-comments__toggle:hover {
background: var(--ap-surface-2);
color: var(--ap-text);
}
.ap-comments__act:focus-visible,
.ap-comments__toggle:focus-visible {
outline: 2px solid var(--ap-focus);
outline-offset: 0;
}
.ap-comments__act[aria-expanded="true"] {
background: var(--ap-accent-soft);
color: var(--ap-accent-soft-text);
}
.ap-comments__act svg,
.ap-comments__toggle svg {
width: 16px;
height: 16px;
flex-shrink: 0;
fill: none;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.ap-comments__toggle {
margin: 8px 0 0 44px;
color: var(--ap-accent-text);
}
.ap-comments__toggle svg {
transition: rotate var(--ap-duration) var(--ap-ease);
}
.ap-comments__toggle[aria-expanded="false"] svg {
rotate: -90deg;
}
/* The reply box, the edit box and the delete question, moved into place */
.ap-comments__form {
display: grid;
gap: 6px;
margin-top: 10px;
padding: 14px;
border: 1px solid var(--ap-border);
border-radius: var(--ap-radius);
background: var(--ap-surface-2);
animation: ap-comments-in 180ms var(--ap-ease);
}
.ap-comments__c + .ap-comments__form {
margin-left: 52px;
}
.ap-comments__replies .ap-comments__c + .ap-comments__form {
margin-left: 44px;
}
.ap-comments__form textarea.ap-input {
min-height: 72px;
}
.ap-comments__btns {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
margin-top: 4px;
}
.ap-comments__confirm {
display: grid;
gap: 8px;
margin-top: 10px;
padding: 12px 14px;
border: 1px solid var(--ap-danger);
border-radius: var(--ap-radius);
background: var(--ap-danger-soft);
animation: ap-comments-in 180ms var(--ap-ease);
}
.ap-comments__q {
margin: 0;
color: var(--ap-danger);
font-weight: 600;
}
.ap-comments__confirm .ap-comments__btns {
justify-content: flex-start;
margin-top: 0;
}
.ap-comments__vh {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
@keyframes ap-comments-in {
from { opacity: 0; transform: translateY(-4px); }
}
@container (max-width: 440px) {
.ap-comments { padding: 18px 16px 20px; }
.ap-comments__c { gap: 10px; }
.ap-comments__avatar { width: 32px; height: 32px; font-size: .75rem; }
.ap-comments__replies { margin-left: 15px; padding-left: 14px; }
.ap-comments__replies .ap-comments__avatar { width: 28px; height: 28px; }
.ap-comments__toggle { margin-left: 34px; }
.ap-comments__c + .ap-comments__form,
.ap-comments__replies .ap-comments__c + .ap-comments__form { margin-left: 0; }
.ap-comments__bar .ap-btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
.ap-comments__form,
.ap-comments__confirm { animation: none; }
.ap-comments__toggle svg { transition: none; }
}
/**
* Comment thread: articles named by their author, replies as nested lists,
* a reply box that opens under the comment it answers, collapsible threads,
* and edit or delete (with a question first) for your own comments.
*
* Markup: [data-ap-comments] holding a heading with the total
* ([data-ap-cmt-total]), a role=status, the new-comment form
* ([data-ap-cmt-new][data-max]), an ol of comments (li > article, then an
* optional toggle button[data-ap-cmt-toggle] and ol.ap-comments__replies),
* one spare reply form, edit form and delete question that the script moves
* into place, and a polite region ([data-ap-cmt-say]) for errors.
*/
const LIMIT_WORDS = (left) => (left < 0
? (left === -1 ? "character too many" : "characters too many")
: (left === 1 ? "character left" : "characters left"));
// One piece of text per count, so a translation can put the number anywhere.
const TOGGLE_WORDS = (n, open) => `${open ? "Hide" : "Show"} ${n} ${n === 1 ? "reply" : "replies"}`;
export function init(root) {
const ac = new AbortController();
const on = (target, type, fn) => target.addEventListener(type, fn, { signal: ac.signal });
const heading = root.querySelector(".ap-comments__count");
const total = root.querySelector("[data-ap-cmt-total]");
const status = root.querySelector("[role=status]");
const say = root.querySelector("[data-ap-cmt-say]");
const list = root.querySelector(".ap-comments__list");
const spare = root.querySelector(".ap-comments__spare");
const newForm = root.querySelector("[data-ap-cmt-new]");
const replyForm = root.querySelector("[data-ap-cmt-replyform]");
const replyLabel = replyForm.querySelector("[data-ap-cmt-replylabel]");
const editForm = root.querySelector("[data-ap-cmt-editform]");
const confirm = root.querySelector("[data-ap-cmt-confirm]");
const max = Number(newForm.dataset.max) || 500;
// Your own comment, as it was at the start: the model for new ones.
const ownModel = root.querySelector("article[data-own]")?.closest("li").cloneNode(true);
let replyingFrom = null; // the Reply button whose box is open
let editing = null; // the article being edited
let deleting = null; // the article whose delete question is open
let seq = 0;
const field = (form) => form.querySelector("textarea");
const articleOf = (el) => el.closest("article");
const threadOf = (el) => el.closest(".ap-comments__list > li");
function tell(text) {
status.textContent = "";
requestAnimationFrame(() => { status.textContent = text; });
}
function speak(text) {
say.textContent = "";
requestAnimationFrame(() => { say.textContent = text; });
}
/* ── Errors: shown under the box, tied to it only while they show ── */
function setError(form, message) {
const input = field(form);
const error = form.querySelector(".ap-error");
if (message) error.querySelector("span").textContent = message;
error.hidden = !message;
const ids = (input.getAttribute("aria-describedby") || "").split(/\s+/).filter((id) => id && id !== error.id);
if (message) ids.push(error.id);
if (ids.length) input.setAttribute("aria-describedby", ids.join(" "));
else input.removeAttribute("aria-describedby");
if (message) input.setAttribute("aria-invalid", "true");
else input.removeAttribute("aria-invalid");
}
function refuse(form, message) {
setError(form, message);
const input = field(form);
// Already in the box, a new description is not reread: say it instead.
if (document.activeElement === input) speak(form.querySelector(".ap-error").textContent.trim());
else input.focus();
}
/* ── Counts ── */
function addToTotal(by) {
total.textContent = String(Number(total.textContent) + by);
}
function paintToggle(thread) {
const replies = thread.querySelector(":scope > .ap-comments__replies");
const toggle = thread.querySelector(":scope > .ap-comments__toggle");
if (!replies || !toggle) return;
const n = replies.children.length;
if (!n) {
toggle.remove();
replies.remove();
return;
}
toggle.querySelector("span").textContent = TOGGLE_WORDS(n, toggle.getAttribute("aria-expanded") === "true");
}
function setThreadOpen(thread, open) {
const toggle = thread.querySelector(":scope > .ap-comments__toggle");
const replies = thread.querySelector(":scope > .ap-comments__replies");
if (!open) {
// Anything open inside goes first, quietly.
if (replyingFrom && replies.contains(replyingFrom)) closeReply(false);
if (editing && replies.contains(editing)) closeEdit(false);
if (deleting && replies.contains(deleting)) closeConfirm(false);
}
toggle.setAttribute("aria-expanded", String(open));
replies.hidden = !open;
paintToggle(thread);
}
/** The replies list of a thread, made (with its toggle) if it has none yet. */
function repliesOf(thread) {
let replies = thread.querySelector(":scope > .ap-comments__replies");
if (replies) return replies;
const parent = thread.querySelector(":scope > article");
replies = document.createElement("ol");
replies.className = "ap-comments__replies";
replies.id = `${parent.id}-replies`;
const toggle = document.createElement("button");
toggle.type = "button";
toggle.className = "ap-comments__toggle";
toggle.setAttribute("data-ap-cmt-toggle", "");
toggle.setAttribute("aria-expanded", "true");
toggle.setAttribute("aria-controls", replies.id);
const chevron = root.querySelector(".ap-comments__toggle svg");
if (chevron) toggle.append(chevron.cloneNode(true));
toggle.append(document.createElement("span"));
thread.append(toggle, replies);
return replies;
}
/* ── A new comment of yours, made from the model ── */
function ownComment(text) {
const li = ownModel.cloneNode(true);
const article = li.querySelector("article");
seq += 1;
const id = `cmt-you-${seq}`;
article.id = id;
article.setAttribute("aria-labelledby", `${id}-who`);
li.querySelector(".ap-comments__who").id = `${id}-who`;
li.querySelector(".ap-comments__edited")?.remove();
const now = new Date();
const locale = document.documentElement.lang.startsWith("hi") ? "hi-IN" : "en-GB";
const full = new Intl.DateTimeFormat(locale, { day: "numeric", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(now);
const time = li.querySelector("time");
time.dateTime = now.toISOString();
time.title = full;
time.firstChild.textContent = "Just now";
time.querySelector(".ap-comments__vh > span").textContent = full;
li.querySelector(".ap-comments__text").textContent = text;
return li;
}
/* ── Close whatever is open ── */
function closeAll() {
closeReply(false);
closeEdit(false);
closeConfirm(false);
}
/* ── Reply ── */
function openReply(button) {
if (replyingFrom === button) {
field(replyForm).focus();
return;
}
closeAll();
replyingFrom = button;
button.setAttribute("aria-expanded", "true");
button.setAttribute("aria-controls", replyForm.id);
replyLabel.textContent = button.getAttribute("aria-label");
setError(replyForm, "");
field(replyForm).value = "";
articleOf(button).after(replyForm);
replyForm.hidden = false;
field(replyForm).focus();
}
function closeReply(returnFocus) {
if (!replyingFrom) return;
const button = replyingFrom;
replyingFrom = null;
replyForm.hidden = true;
spare.append(replyForm);
button.setAttribute("aria-expanded", "false");
button.removeAttribute("aria-controls");
if (returnFocus) button.focus();
}
function postReply(event) {
event.preventDefault();
const text = field(replyForm).value.trim();
if (!text) {
refuse(replyForm, "Write a reply first.");
return;
}
const thread = threadOf(replyingFrom);
closeReply(false);
const li = ownComment(text);
repliesOf(thread).append(li);
setThreadOpen(thread, true);
addToTotal(1);
li.querySelector("article").focus();
tell("Reply posted");
}
/* ── Edit ── */
function openEdit(article) {
closeAll();
editing = article;
const text = article.querySelector(".ap-comments__text");
const acts = article.querySelector(".ap-comments__acts");
setError(editForm, "");
field(editForm).value = text.textContent;
text.hidden = true;
acts.hidden = true;
text.after(editForm);
editForm.hidden = false;
const input = field(editForm);
input.focus();
input.setSelectionRange(input.value.length, input.value.length);
}
function closeEdit(returnFocus) {
if (!editing) return;
const article = editing;
editing = null;
editForm.hidden = true;
spare.append(editForm);
article.querySelector(".ap-comments__text").hidden = false;
article.querySelector(".ap-comments__acts").hidden = false;
if (returnFocus) article.querySelector("[data-ap-cmt-edit]").focus();
}
function saveEdit(event) {
event.preventDefault();
const text = field(editForm).value.trim();
if (!text) {
refuse(editForm, "Write something, or delete the comment instead.");
return;
}
const article = editing;
const target = article.querySelector(".ap-comments__text");
const changed = target.textContent !== text;
target.textContent = text;
if (changed && !article.querySelector(".ap-comments__edited")) {
const mark = document.createElement("span");
mark.className = "ap-comments__edited";
mark.textContent = "Edited";
article.querySelector(".ap-comments__meta").append(" ", mark);
}
closeEdit(true);
if (changed) tell("Comment updated");
}
/* ── Delete, after a question ── */
function openConfirm(article) {
closeAll();
deleting = article;
const acts = article.querySelector(".ap-comments__acts");
acts.hidden = true;
acts.after(confirm);
confirm.hidden = false;
// The safe choice takes focus.
confirm.querySelector("[data-ap-cmt-keep]").focus();
}
function closeConfirm(returnFocus) {
if (!deleting) return;
const article = deleting;
deleting = null;
confirm.hidden = true;
spare.append(confirm);
article.querySelector(".ap-comments__acts").hidden = false;
if (returnFocus) article.querySelector("[data-ap-cmt-delete]").focus();
}
function remove() {
const article = deleting;
closeConfirm(false);
const li = article.closest("li");
const thread = threadOf(article);
const isReply = thread !== li;
// Focus goes to the comment before it, or to the heading.
const articles = [...root.querySelectorAll(".ap-comments__list article")].filter((a) => !a.closest("[hidden]"));
const before = articles[articles.indexOf(article) - 1];
const gone = li.querySelectorAll("article").length; // with any replies under it
li.remove();
if (isReply) paintToggle(thread);
addToTotal(-gone);
(before && before.isConnected ? before : heading).focus();
tell("Comment deleted");
}
/* ── New comment ── */
function paintCount() {
const left = max - [...field(newForm).value].length;
newForm.querySelector("[data-ap-cmt-left]").textContent = String(Math.abs(left));
const words = newForm.querySelector("[data-ap-cmt-words]");
const next = LIMIT_WORDS(left);
if (words.dataset.en !== next) {
words.textContent = next;
words.dataset.en = next;
}
newForm.querySelector(".ap-comments__left").toggleAttribute("data-over", left < 0);
return left;
}
function postComment(event) {
event.preventDefault();
const input = field(newForm);
const text = input.value.trim();
const left = paintCount();
if (!text) {
refuse(newForm, "Write a comment first.");
return;
}
if (left < 0) {
refuse(newForm, "Your comment is too long. Shorten it, then post.");
return;
}
setError(newForm, "");
closeAll();
const li = ownComment(text);
list.append(li);
addToTotal(1);
input.value = "";
paintCount();
li.querySelector("article").focus();
tell("Comment posted");
}
/* ── Wiring ── */
function onClick(event) {
const t = event.target;
const reply = t.closest("[data-ap-cmt-reply]");
if (reply) return openReply(reply);
const toggle = t.closest("[data-ap-cmt-toggle]");
if (toggle) return setThreadOpen(threadOf(toggle), toggle.getAttribute("aria-expanded") !== "true");
if (t.closest("[data-ap-cmt-edit]")) return openEdit(articleOf(t));
if (t.closest("[data-ap-cmt-delete]")) return openConfirm(articleOf(t));
if (t.closest("[data-ap-cmt-keep]")) return closeConfirm(true);
if (t.closest("[data-ap-cmt-remove]")) return remove();
if (t.closest("[data-ap-cmt-cancel]")) {
if (replyForm.contains(t)) closeReply(true);
else closeEdit(true);
}
return undefined;
}
function onKeydown(event) {
if (event.key !== "Escape") return;
const t = event.target;
if (replyForm.contains(t)) closeReply(true);
else if (editForm.contains(t)) closeEdit(true);
else if (confirm.contains(t)) closeConfirm(true);
else return;
event.preventDefault();
}
function onInput(event) {
const form = event.target.form;
if (form === newForm) paintCount();
// An error goes as soon as there is something to post.
if (form && field(form).getAttribute("aria-invalid") === "true" && field(form).value.trim()) {
if (form !== newForm || paintCount() >= 0) setError(form, "");
}
}
on(root, "click", onClick);
on(root, "keydown", onKeydown);
on(root, "input", onInput);
on(newForm, "submit", postComment);
on(replyForm, "submit", postReply);
on(editForm, "submit", saveEdit);
paintCount();
return () => ac.abort();
}
for (const root of document.querySelectorAll("[data-ap-comments]")) init(root);
/* Design tokens for the pattern components. Light by default, dark when the
system asks for it; set data-theme="dark" on :root to force dark. */
:root {
--ap-radius-sm: 8px;
--ap-radius: 12px;
--ap-radius-lg: 16px;
--ap-radius-full: 999px;
--ap-font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--ap-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
--ap-ease: cubic-bezier(.2, .8, .2, 1);
--ap-duration: 180ms;
--ap-target: 44px;
--ap-bg: #F4F4F5;
--ap-surface: #FFFFFF;
--ap-surface-2: #F4F4F5;
--ap-surface-3: #E4E4E7;
--ap-border: #E4E4E7;
--ap-border-strong: #76767F;
--ap-text: #18181B;
--ap-text-2: #3F3F46;
--ap-text-3: #5E5E66;
--ap-accent: #4F46E5;
--ap-accent-hover: #4338CA;
--ap-on-accent: #FFFFFF;
--ap-accent-text: #4338CA;
--ap-accent-soft: #EEF2FF;
--ap-accent-soft-text: #3730A3;
--ap-focus: #4F46E5;
--ap-danger: #B91C1C;
--ap-danger-soft: #FEF2F2;
--ap-success: #15803D;
--ap-success-soft: #F0FDF4;
--ap-warning: #A15C07;
--ap-warning-soft: #FEFCE8;
--ap-info: #1D4ED8;
--ap-info-soft: #EFF6FF;
--ap-scrim: rgb(9 9 11 / .48);
--ap-shadow-sm: 0 1px 2px rgb(9 9 11 / .06);
--ap-shadow-md: 0 1px 2px rgb(9 9 11 / .05), 0 6px 16px -4px rgb(9 9 11 / .1);
--ap-shadow-lg: 0 2px 6px rgb(9 9 11 / .06), 0 20px 40px -12px rgb(9 9 11 / .22);
--ap-light-bg: #F4F4F5;
--ap-light-surface: #FFFFFF;
--ap-light-surface-2: #F4F4F5;
--ap-light-surface-3: #E4E4E7;
--ap-light-border: #E4E4E7;
--ap-light-border-strong: #76767F;
--ap-light-text: #18181B;
--ap-light-text-2: #3F3F46;
--ap-light-text-3: #5E5E66;
--ap-light-accent: #4F46E5;
--ap-light-accent-hover: #4338CA;
--ap-light-on-accent: #FFFFFF;
--ap-light-accent-text: #4338CA;
--ap-light-accent-soft: #EEF2FF;
--ap-light-accent-soft-text: #3730A3;
--ap-light-focus: #4F46E5;
--ap-light-danger: #B91C1C;
--ap-light-danger-soft: #FEF2F2;
--ap-light-success: #15803D;
--ap-light-success-soft: #F0FDF4;
--ap-light-warning: #A15C07;
--ap-light-warning-soft: #FEFCE8;
--ap-light-info: #1D4ED8;
--ap-light-info-soft: #EFF6FF;
--ap-light-scrim: rgb(9 9 11 / .48);
--ap-light-shadow-sm: 0 1px 2px rgb(9 9 11 / .06);
--ap-light-shadow-md: 0 1px 2px rgb(9 9 11 / .05), 0 6px 16px -4px rgb(9 9 11 / .1);
--ap-light-shadow-lg: 0 2px 6px rgb(9 9 11 / .06), 0 20px 40px -12px rgb(9 9 11 / .22);
--ap-dark-bg: #09090B;
--ap-dark-surface: #18181B;
--ap-dark-surface-2: #27272A;
--ap-dark-surface-3: #3F3F46;
--ap-dark-border: #2E2E33;
--ap-dark-border-strong: #8E8E97;
--ap-dark-text: #FAFAFA;
--ap-dark-text-2: #D4D4D8;
--ap-dark-text-3: #A1A1AA;
--ap-dark-accent: #818CF8;
--ap-dark-accent-hover: #A5B4FC;
--ap-dark-on-accent: #0C0A1F;
--ap-dark-accent-text: #A5B4FC;
--ap-dark-accent-soft: #1E1B4B;
--ap-dark-accent-soft-text: #C7D2FE;
--ap-dark-focus: #A5B4FC;
--ap-dark-danger: #F87171;
--ap-dark-danger-soft: #2A1215;
--ap-dark-success: #4ADE80;
--ap-dark-success-soft: #0F2A1A;
--ap-dark-warning: #FACC15;
--ap-dark-warning-soft: #2A2410;
--ap-dark-info: #60A5FA;
--ap-dark-info-soft: #0F1D33;
--ap-dark-scrim: rgb(0 0 0 / .62);
--ap-dark-shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
--ap-dark-shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -6px rgb(0 0 0 / .5);
--ap-dark-shadow-lg: 0 2px 8px rgb(0 0 0 / .45), 0 24px 48px -12px rgb(0 0 0 / .7);
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--ap-bg: #09090B;
--ap-surface: #18181B;
--ap-surface-2: #27272A;
--ap-surface-3: #3F3F46;
--ap-border: #2E2E33;
--ap-border-strong: #8E8E97;
--ap-text: #FAFAFA;
--ap-text-2: #D4D4D8;
--ap-text-3: #A1A1AA;
--ap-accent: #818CF8;
--ap-accent-hover: #A5B4FC;
--ap-on-accent: #0C0A1F;
--ap-accent-text: #A5B4FC;
--ap-accent-soft: #1E1B4B;
--ap-accent-soft-text: #C7D2FE;
--ap-focus: #A5B4FC;
--ap-danger: #F87171;
--ap-danger-soft: #2A1215;
--ap-success: #4ADE80;
--ap-success-soft: #0F2A1A;
--ap-warning: #FACC15;
--ap-warning-soft: #2A2410;
--ap-info: #60A5FA;
--ap-info-soft: #0F1D33;
--ap-scrim: rgb(0 0 0 / .62);
--ap-shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
--ap-shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -6px rgb(0 0 0 / .5);
--ap-shadow-lg: 0 2px 8px rgb(0 0 0 / .45), 0 24px 48px -12px rgb(0 0 0 / .7);
}
}
:root[data-theme="dark"] {
--ap-bg: #09090B;
--ap-surface: #18181B;
--ap-surface-2: #27272A;
--ap-surface-3: #3F3F46;
--ap-border: #2E2E33;
--ap-border-strong: #8E8E97;
--ap-text: #FAFAFA;
--ap-text-2: #D4D4D8;
--ap-text-3: #A1A1AA;
--ap-accent: #818CF8;
--ap-accent-hover: #A5B4FC;
--ap-on-accent: #0C0A1F;
--ap-accent-text: #A5B4FC;
--ap-accent-soft: #1E1B4B;
--ap-accent-soft-text: #C7D2FE;
--ap-focus: #A5B4FC;
--ap-danger: #F87171;
--ap-danger-soft: #2A1215;
--ap-success: #4ADE80;
--ap-success-soft: #0F2A1A;
--ap-warning: #FACC15;
--ap-warning-soft: #2A2410;
--ap-info: #60A5FA;
--ap-info-soft: #0F1D33;
--ap-scrim: rgb(0 0 0 / .62);
--ap-shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
--ap-shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -6px rgb(0 0 0 / .5);
--ap-shadow-lg: 0 2px 8px rgb(0 0 0 / .45), 0 24px 48px -12px rgb(0 0 0 / .7);
}
डब्ल्यूसीएजी 2.2
यह किन मानदंडों को पूरा करता है
वे सफलता मानदंड जिनका यह पैटर्न ध्यान रखता है, और कैसे।
-
1.3.1 जानकारी और संबंध
स्तर A
टिप्पणियाँ अपने लेखक के नाम वाले आर्टिकल हैं, जवाब उस टिप्पणी के अंदर नेस्टेड सूचियाँ हैं जिसका वे जवाब देते हैं, और गिनती हेडिंग का हिस्सा है।
-
2.1.1 कीबोर्ड
स्तर A
जवाब देना, थ्रेड समेटना, एडिट और डिलीट करना, सब साधारण बटनों के साथ कीबोर्ड से होता है।
-
2.4.3 फ़ोकस क्रम
स्तर A
जवाब या एडिट बॉक्स खोलने पर फ़ोकस उसमें जाता है; पोस्ट करने पर फ़ोकस नई टिप्पणी पर जाता है; रद्द करने पर वह उस बटन पर लौटता है जिससे शुरुआत हुई।
-
3.3.1 त्रुटि पहचान
स्तर A
ख़ाली या बहुत लंबी टिप्पणी पोस्ट नहीं होती; बॉक्स के नीचे एक त्रुटि बताती है क्यों, जो बॉक्स से जुड़ी होती है और घोषित होती है।
-
3.3.4 त्रुटि निवारण (क़ानूनी, वित्तीय, डेटा)
स्तर AA
डिलीट करने से पहले अपनी जगह पर पूछा जाता है, रद्द पर फ़ोकस के साथ, इसलिए एक भूल से दबाई गई कुंजी कभी टिप्पणी नहीं हटाती।
-
4.1.2 नाम, भूमिका, मान
स्तर A
हर जवाब दें बटन और जवाब बॉक्स बताता है कि वह किसे जवाब देता है; थ्रेड टॉगल और जवाब दें बटन aria-expanded से बताते हैं कि वे खुले हैं या नहीं।
-
4.1.3 स्टेटस मैसेज
स्तर AA
टिप्पणी पोस्ट हुई, जवाब पोस्ट हुआ, टिप्पणी अपडेट हुई और टिप्पणी डिलीट हुई एक स्टेटस क्षेत्र में लिखे जाते हैं, जो फ़ोकस हिलाए बिना पढ़े जाते हैं।
उपयोग
इसे कब इस्तेमाल करें
इसे अपनाएँ
- किसी लेख, उत्पाद, डिज़ाइन या काम के नीचे की चर्चाएँ, जहाँ जवाब किसी एक टिप्पणी का उत्तर देते हैं।
- समीक्षा थ्रेड जहाँ लोग अपना लिखा एडिट करते हैं या हटाते हैं।
कुछ और इस्तेमाल करें
- कुछ लोगों के बीच तुरंत की बातचीत: उसके लिए लाइव लॉग वाली चैट बेहतर है।
- एक स्तर से गहरे थ्रेड: जवाबों के एक स्तर के बाद नेस्टिंग को सुनकर और देखकर समझना मुश्किल होता है।
- छोटी रेटिंग या प्रतिक्रियाएँ: प्रतिक्रिया पट्टी कम में ज़्यादा कहती है।
आम विफलताएँ
आमतौर पर यह कहाँ गलत होता है
ऐसे जवाब बटन जिन पर सिर्फ़ जवाब दें लिखा हो
एक जैसे जवाब दें बटनों की सूची संदर्भ के बिना बेमानी है। यहाँ हर बटन का नाम आशा को जवाब दें, नेहा को जवाब दें वगैरह है।
कहीं और खुलने वाला जवाब बॉक्स
पेज के ऊपर खुला बॉक्स, या बटन पर छूटा फ़ोकस, लोगों को उसे खोजने पर मजबूर करता है। यहाँ वह टिप्पणी के नीचे खुलता है और फ़ोकस लेता है।
पोस्ट करने के बाद फ़ोकस खो जाना
अगर फ़ोकस किसी ऐसे बटन पर रहे जो अभी-अभी ग़ायब हुआ है, तो कीबोर्ड इस्तेमाल करने वाले पेज के ऊपर पहुँच जाते हैं। फ़ोकस नई टिप्पणी पर जाता है, और स्टेटस इसकी पुष्टि करता है।
बिना वापसी के रास्ते वाला डिलीट
एडिट के बगल में एक बार दबाने वाला डिलीट ग़लती से दब जाना आसान है। यहाँ सवाल अपनी जगह पर आता है, रद्द पर फ़ोकस के साथ।
जवाब का इकलौता संकेत इंडेंटेशन
इंडेंट किए गए div नेस्टेड दिखते हैं पर सपाट पढ़े जाते हैं। नेस्टेड सूचियाँ हर जवाब की थ्रेड में जगह स्क्रीन रीडर को भी बताती हैं।
बिना असली तारीख़ की सापेक्ष तारीख़ें
"3 घंटे पहले" पुराना पड़ जाता है और अस्पष्ट है। time एलिमेंट सटीक तारीख़ और समय रखता है, और स्क्रीन रीडर उसे सापेक्ष समय के बाद सुनाते हैं।
नोट्स
इसे बनाना
- एक जवाब फ़ॉर्म, एक एडिट फ़ॉर्म और एक डिलीट वाला सवाल ज़रूरत की जगह ले जाए जाते हैं, इसलिए एक समय में एक से ज़्यादा कभी खुला नहीं रहता और id अनोखे रहते हैं।
- नज़र से छिपी पूरी तारीख़ time एलिमेंट के अंदर सापेक्ष समय के बाद है; title एट्रिब्यूट माउस इस्तेमाल करने वालों को होवर पर वही तारीख़ दिखाता है।
- थ्रेड टॉगल aria-expanded रखते हैं और अपने शब्द भी छिपाएँ और दिखाएँ के बीच बदलते हैं, जैसा GOV.UK अकॉर्डियन करता है; दोनों एक ही बात कहते हैं, इसलिए कभी असहमत नहीं होते।
- समेटे हुए थ्रेड में जवाब पोस्ट करने पर पहले थ्रेड खुलता है, ताकि फ़ोकस कभी किसी छिपी चीज़ पर न पहुँचे।
- हर गिनती वाला वाक्यांश (3 जवाब छिपाएँ) टेक्स्ट का एक ही टुकड़ा है, ताकि अनुवाद शब्दों और संख्या का क्रम बदल सकें।
स्रोत: WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: डिस्क्लोज़र · एचटीएमएल: article एलिमेंट
लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ
टिप्पणियाँ 6
आशा राव
मोज़ों के दो जोड़े साथ रखें। उधेवाड़ी के बाद रास्ता एक धारा बन जाता है, और गीले पैरों में जल्दी छाले पड़ते हैं।
विक्रम शेट्टी
सहमत। जल्दी सूखने वाले मोज़े हर रुपये के लायक थे।
नेहा कुलकर्णी
क्या रास्ते पर निशान हैं, या हमें लोनावला से गाइड चाहिए?
आप
गाँव तक निशान हैं। उसके बाद किले की दीवारों के साथ चलें।
रोहन मेहता
7 बजे से पहले निकलें। लोनावला लौटने वाली आख़िरी साझा जीपें 5 बजे तक निकल जाती हैं।
आशा राव
और नकद रखें। नेटवर्क जाने पर गाँव की दुकानें UPI नहीं ले पातीं।
यह टिप्पणी डिलीट करें? इसे पहले जैसा नहीं किया जा सकता।