-
Notifications
You must be signed in to change notification settings - Fork 5
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
Toast component #148
base: main
Are you sure you want to change the base?
Toast component #148
Conversation
content/body/toast.php
Outdated
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Accessible Toast Notifications</title> | ||
<link rel="stylesheet" href="toast.css"> | ||
<link rel="stylesheet" href="app.css"> | ||
</head> | ||
<body> |
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.
These elements shouldn't be included in this /content/body/toast.php file. They would either already be automatically included when the page is initially compiled, or should be included in the /content/head/toast.php file.
content/body/toast.php
Outdated
{ | ||
"label": "Create markup", | ||
"highlight": "data-tooltip", | ||
"notes": "Our script uses the <code>data-tooltip</code> attribute instead of the <code>title</code> attribute, since <strong>title</strong> is rendered by user agents by default and cannot be styled." |
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.
Isn't the data-tooltip
just a attribute that the Enable custom tooltip component uses? I don't think that sites that are missing the Enable custom tooltip will know what to do with this attribute.
less/toast-demo.less
Outdated
@margin: 20px; | ||
@gap: 10px; | ||
@font-size: 16px; |
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.
Instead of pixels, you should be using rem or em units in order to make text resizing be possible. This is especially important for font sizes.
@margin: 20px; | |
@gap: 10px; | |
@font-size: 16px; | |
@margin: 1.25rem; | |
@gap: 0.625rem; | |
@font-size: 1rem; |
@toast-padding: 10px; | ||
@toast-border-radius: 5px; | ||
@toast-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
@toast-transition: all 0.5s ease-in-out; | ||
@toast-close-color: @toast-color; | ||
@toast-close-hover-color: #ff0000; | ||
@rack-background: rgba(241, 241, 241, 0.9); | ||
@rack-border: 1px solid #ddd; | ||
@rack-padding: 10px; | ||
@rack-width: 300px; | ||
@rack-max-height: 400px; |
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.
Again, consider using rem or em units instead of pixels whenever you can in this file.
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.
For this and above, I am okay with just font-sizing and anything needed for that done in rems. For margins, padding, etc, it is okay to use px as long as it doesn't affect legibility (although it is not wrong to do so if it is more aesthetically pleasing).
less/toast.less
Outdated
|
||
&.bottom-right, | ||
&.bottom-left, | ||
&.bottom-center { |
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.
Most of Enable is written using BEM. The structure should be like:
.toast {
&__container {
&--bottom-right {
}
}
&__rack {
}
(This is not exhaustive .. it's just an example)
concat.txt
Outdated
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.
What is this for?
content/body/toast.php
Outdated
<li>Toasts should support different levels of severity (normal, error, warning, success), each with a unique color for visual distinction.</li> | ||
</ol> | ||
<p> | ||
Our implementation ensures that toasts are fully accessible and follow best practices for ARIA and keyboard interaction. When a toast appears, it is announced to screen readers. Toasts can be configured to stay visible for a set amount of time or until manually dismissed by the user. Additionally, all toasts are stored in a toast rack for future reference. |
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.
We may want to remove the set amount of time part. Let's discuss on your demo.
css/app.css
Outdated
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 is not a LESS file. All CSS must be in LESS.
- The name
app.css
is not specific. It should describe what it's used for. Is this for the demo, or the component?
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 this is an old issue, both less and css files are in repository, which I think is the correct pattern
import toastModule from '../modules/toast.js'; | ||
|
||
const app = new (function () { | ||
console.log('toast demo!!!'); |
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.
Please remove. I am surprised this wasn't caught by unit testing.
|
||
// Initialize the toast rack | ||
this.rackContent = document.getElementById('rackContent'); | ||
this.toggleRackButton = document.getElementById('toggleRackButton'); |
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.
All CSS classes and IDs should be namespaced.
Use something like #enable-toast__rack-content
and #enable-toast__rack-back-button
.
|
||
// Update the visible toasts according to the max visible limit | ||
updateVisibleToasts() { | ||
console.log("Updating visible toasts"); |
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.
Avoid keeping console.log() statements in your code. If they are absolutely necessary, use console.info(). I don't think this is, though.
js/modules/es4/toast.js
Outdated
this.visibleQueue.forEach((toast, index) => { | ||
const toastElement = this.container.querySelector(`[data-id="${toast.id}"]`); | ||
if (index < this.maxVisible) { | ||
toastElement.classList.add('toast-visible'); |
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.
CSS classes should enforce BEM:
enable-toast--visible
js/modules/toast.js
Outdated
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.
Sorry -- all the comments for the ES4 code was meant for this file.
less/toast-demo.less
Outdated
@font-size: 1rem; // 16px converted to rem | ||
|
||
// Controls styles | ||
.controls { |
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.
BEM should be used here. Let's fix this and the toast.less file. Discuss with me if you need guidance.
less/toast.less
Outdated
|
||
&.enable-toast__container--bottom-right, | ||
&.enable-toast__container--bottom-left, | ||
&.enable-toast__container--bottom-center { |
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.
You should just use
&__container--bottom-right,
&__container--bottom-left,
&__container--bottom-center {
...
}
The point of BEM is ensure the components DOM structure can be changed completely and things will be styled the same. While this may not be a concern here, it is a concern for the selectors below.
What is relevant here is that BEM also flattens CSS specificity.
Let's talk when you have time.
8fc0d96
to
1486b94
Compare
No description provided.