Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Add refresh buttons to view title bars #22

Merged
merged 5 commits into from
Aug 23, 2019

Conversation

jacobcoughenour
Copy link
Contributor

Related to #7 #18 and #19

I ported the icons from chrome devtools to add a element. You have to use "--spritesheet-position" to get the desired icon for now. I had to tweak the icon styles from chrome to get them to work in firefox.

As a use case, I added "refresh" icon buttons to the title bars for some of the views. They currently don't do anything when clicked.

Copy link
Member

@jsantell jsantell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 this is great, thanks! some comments on component design inline. For the common-elements, not sure how inspectorCommon.css that's already included plays into that, maybe can start moving the relevant pieces into the DevtoolsIconButtonElement? What do you think?

@@ -0,0 +1,83 @@
export default `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these styles are already included via src/app/styles/inspectorCommon.css -- I like the idea of moving it with the component though. Is there any reason this is a separate file/string rather than in the style element of the component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the icon styles are already in inspectorCommon.css, they weren't being applied to the DevtoolsIconButtonElement (is this a shadow-dom thing?). I put the styles into ui-icon.js so they can be used by anything that needs the sprite sheets.

@@ -83,7 +83,9 @@ export default class MaterialViewElement extends BaseElement {
display: flex;
}
</style>
<title-bar title="Material View"></title-bar>
<title-bar title="Material View">
<devtools-icon-button sheet-variant="large" icon-style="--spritesheet-position:-84px 48px; width: 28px; height: 24px;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these values of sheet-variant and icon-style can be the default styles?

Passing in a style string to a child component feels a bit like circumventing cascading styles, or a bit React-y -- setting the style here with CSS vars will cascade down to the devtools-icon-button's span, or if using these values as a default, then in the :host style for the icon, e.g.
<devtools-icon-button style="--spritesheet-position: -84px 48px;"></devtools-icon-button>

Or when overriding default size
<devtools-icon-button style="--spritesheet-position: -84px 48px; --button-width: 50px; --button-height: 50px"></devtools-icon-button>

Exposing CSS variables as an API and just using the cascade seems to fit the style of LitElement/web components; what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll move the icon span into its own class and move the ui-icon.js styles to there as well. Maybe it could look something like <devtools-icon glyph="refresh"></devtools-icon> ?

@jacobcoughenour
Copy link
Contributor Author

jacobcoughenour commented Jul 21, 2019

I moved ui-icon into its own element <devtools-icon>. I ended up removing most of the original icon styles in the process in favor of using template variables for the size and filename.

The icons can now be accessed by name e.g. <devtools-icon icon="refresh"> and <devtools-icon-button icon="refresh">

@jsantell
Copy link
Member

@jacobcoughenour sorry for the wait, looks great and thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants