-
Notifications
You must be signed in to change notification settings - Fork 97
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
Component: ebay-notice #28
Conversation
package.json
Outdated
@@ -43,7 +43,7 @@ | |||
"marko-components" | |||
], | |||
"devDependencies": { | |||
"@ebay/skin": "^3.3.0-0", | |||
"@ebay/skin": "^3.4.0-0", |
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 can change this to 3.4.0 now. We have verified it (don't forget to regenerate yarn.lock). Or you can simply rebase and force push my commit from 0.1.0 branch. Up to you. Either way should resolve the conflicts below.
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.
okay I will rebase from 0.1.0
@@ -12,3 +12,5 @@ dist | |||
.browser-refresh | |||
integration/template.marko | |||
integration/browser.json | |||
/.vscode |
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 can let these unrelated changes slip through this time, but team, I'd like us to get into the habit of creating separate PRs for anything unrelated to the main issue at hand. This may seem picky, but imagine if we have to rollback this feature commit (for whatever reason) after it is squashed, we probably wouldn't want to roll back these useful .gitignore
updates too, but that's what would happen (and then we'd have to re-commit them again). The upgrade of skin dependency is another example of this. I know I'm being exceptionally picky in this case. Sorry ;-)
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 can create a different PR for this, I am not sure about creating an issue though
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 me just do that
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 need. Seriously. I was just using this as an example :-)
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.
okay :)
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'm 100% in agreement with this. I know I just try to get improvements in, but small PRs for minor improvements are actually good, too.
Although, I do know there are times when I don't want to forget! So, I guess we create an issue to track it, @ianmcburnie?
level="page" | ||
aria-label-text="this is a notice"> | ||
<p><strong>Error:</strong> Please take another look at the following: | ||
</p> |
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.
Small suggestion, should be all on the same line:
<p><strong>Error:</strong> Please take another look at the following:</p>
OR, on different lines like paragraph below it.
<p>
<strong>Error:</strong> Please take another look at the following:
</p>
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.
same as below
level="inline" | ||
aria-label-text="this is a notice"> | ||
<p> Couldn't load all the items, please try again later. | ||
</p> |
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.
Same comment about whitespace here.
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.
Yes that looks ugly, I will fix it
src/components/ebay-notice/index.js
Outdated
model.type = state.type || defaults.type; | ||
const level = model.level; | ||
const headingTag = (level === 'page') ? | ||
(state.headingTag || constants[level].headingTag) : constants[level].headingTag; |
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.
MINOR: Maybe We should just reset the state.headingTag
beforehand rather than having it with the ||
. Like an intermediary const
?
const level = state.level || defaults.level;
const type = state.type || defaults.type;
let headingTag = state.headingTag || constants[level].headingTag;
if (level !== 'page') {
headingTag = constants[level].headingTag;
}
Just an exploration, to make the logic pretty clear for the next developer who will look at the code of this 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.
hmmm now that I am thinking about it I can do
const headingTag = (level === 'page' && state.headingTag) ? state.headingTag : constants[level].headingTag;
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.
That works! Much easier to understand now.
src/components/ebay-notice/index.js
Outdated
model.renderBody = state.renderBody; | ||
model.class = state.class || ''; | ||
|
||
return model; |
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.
Both the other components (menu, listbox) just use an object returned:
return {
type: state.type,
isRadio: state.isRadio,
isCheckbox: state.isCheckbox,
isNotCheckable: !state.isRadio && !state.isCheckbox,
label: state.label,
expanded: state.expanded,
menuClass: menuClass,
buttonClass: buttonClass,
itemsClass: itemsClass,
role: !state.fake ? 'menu' : null,
items: state.items,
htmlAttributes: state.htmlAttributes
};
@ianmcburnie @yomed Should we enforce a consistent style for code like this, in the lifecycle methods?
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.
okay I can make the changes
<${data.mainTag} | ||
w-bind | ||
aria-labelledby="${data.type}-status-${widget.elId()}" | ||
class="${data.level}-notice ${data.level}-notice--${data.type} ${data.class}" |
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.
To be consistent with the other components, the class creation/management should be moved to index.js
in the getTemplateData
method.
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 was thinking whether I should keep it in index.js
when I sent a PR. Okay I will do it
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 the case of notice I would have to create 3 data classes as all three DOM elements would have different classes according to the input
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.
Maybe just experiment with how you might add classes. Here are two examples:
Menu
https://github.com/eBay/ebayui-core/blob/master/src/components/ebay-menu/index.js#L84-L96
Listbox (soon to be Select)
https://github.com/eBay/ebayui-core/blob/master/src/components/ebay-listbox/index.js#L48-L50
I'm sure you can come up with something to satisfy creating the classes. Also, remember that you can use arrays which make adding the class names very easy.
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.
Okay I will make the changes, thanks! :)
src/components/ebay-notice/index.js
Outdated
const processHtmlAttributes = require('../../common/html-attributes'); | ||
const template = require('./template.marko'); | ||
|
||
|
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.
Remove this extra line. 😁
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.
As a side note, we may want to enforce this through eslint:
https://eslint.org/docs/rules/no-multiple-empty-lines
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 would approve of that. 👍
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.
oops!
@@ -0,0 +1,8 @@ | |||
{ |
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 believe this file (marko-tag.json
) and the marko.json
won't work in Marko v4, and that configuration needs to be moved up into the root marko.json
of the project, per #15.
Therefore, please move this configuration up into the root ./marko.json
.
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.
Oh I missed it, my bad. Will correct it.
src/components/ebay-notice/index.js
Outdated
return input; | ||
} | ||
function getTemplateData(state) { | ||
const model = {}; |
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.
@sharma46bhawana You could also do
const model = Object.assign({}, defaults, state);
and avoid
model.level = state.level || defaults.level;
model.type = state.type || defaults.type;
BTW, the above two lines are repeated twice. Maybe a typo.
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.
nice!
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 I don't need model anymore
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.
Right, you don't need model
any longer.
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.
Looks solid overall, just some minor comments.
src/components/ebay-notice/README.md
Outdated
### `ebay-notice` Usage | ||
|
||
```marko | ||
<ebay-notice heading-tag="h3" type="priority" level="page" aria-label-text="this is a notice"> |
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.
(minor) Would "this is a notice" be used in real world usage of this component? If not, maybe we can improve it to approximate practical usage (across all examples that use this text).
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.
Right, I will change it to @ianmcburnie's suggestion
src/components/ebay-notice/index.js
Outdated
level: 'page', | ||
type: 'confirmation' | ||
}; | ||
function getInitialState(input) { |
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 be able to remove this function entirely -- the default Marko behavior already returns input
.
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.
Okay, I thought that as its in compatibility layer it might still need the getInitialState, if not i will remove it :)
<ebay-notice | ||
type="confirmation" | ||
level="inline" | ||
aria-label-text="this is a notice"> |
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 change all example aria-label-text to one of "Confirmation", "Priority" or "Information".
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.
Okay will do it.
src/components/ebay-notice/README.md
Outdated
`level` | String | No | "inline" or "page" | ||
`type` | String | No | "priority", "confirmation" or "information" | ||
`aria-label-text` | String | No | adding description for the notice for a11y users | ||
`heading-tag` | String | No| used in case of "page" level notices to specify the heading tag according to the notice's placement |
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 suggest we use heading-level
, with a value of 1 to 6. This actually falls in line nicely with aria-level
.
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 actually like that. I will make the changes
I suggest we rename |
You should work with @ianmcburnie on the last bit, though. |
Oh, and there are now conflicts, it appears. |
@ianmcburnie made the changes to make the names, @yomed made the changes you suggested. Please take a look when you get time |
36ceaa0
to
f9d3ef8
Compare
65361ff
to
3c54a29
Compare
src/components/ebay-notice/README.md
Outdated
`class` | String | No | custom class | ||
`type` | String | No | "inline" or "page" | ||
`status` | String | No | "priority", "confirmation" or "information" | ||
`aria-level` | String | No | adding description for the notice for a11y users |
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.
@ianmcburnie Did you intend to have this called aria-level
rather than something like aria-text
or aria-label-text
?
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, my intention was not for it to be aria-level
. Apologies if I caused confusion. Maybe heading-text
? Or icon-aria-label
- whatever would be consistent with other components.
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 aria-text
would be a better.
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.
Okay, let's go with aria-text
. This text is also used to label the region/section (via aria-labelledby) - so I think this choice is a good all round fit.
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.
done
5327982
to
08e61bf
Compare
src/components/ebay-notice/README.md
Outdated
### `ebay-notice` Usage | ||
|
||
```marko | ||
<ebay-notice heading-level="3" status="priority" type="page" aria-level="Priority"> |
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.
Make sure to update the aria-level
reference here
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.
yes will do it now
src/components/ebay-notice/index.js
Outdated
renderBody: input.renderBody, | ||
mainClass: [`${type}-notice`, `${type}-notice--${status}`, input.class], | ||
headingClass: [`${type}-notice__status`], | ||
contentClass: [`${type}-notice__content`] |
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.
headingClass
and contentClass
can be regular strings instead of arrays.
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.
okay makes sense
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.
Nice job Bhawana!
Description
Contains a new component
ebay-notice
which constructs page and inline alerts.Context
As the alerts can be page or inline alerts (see ebay/skin) we want to get that as an input for customisation. Default is set to
page
when no input is provided.For a page alert we have a heading tag in the icon that provides it is ordering with a11y users. To provide that customisation we take the heading-tag as an input for customisation. Default is set to
h2
when no input is provided.As the alerts are differentiated into 3 types:
confirmation
,priority
andinformation
, we take the type as an input for the customisation. Default is set topriority
when no input is provided.References
This will complete issue #5
Screenshots
Page notice with type: priority
Inline notice with type: confirmation