Skip to content
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

Sidebar: Add a sidebar to hold the post settings and inspector #449

Merged
merged 3 commits into from
Apr 19, 2017

Conversation

youknowriad
Copy link
Contributor

This PRs triggers the work on the editor's sidebar. I kept it minimal, just opening and closing an empty sidebar when clicking on "Post Settings".

This probably needs more design ❤️ cc @jasmussen

@youknowriad youknowriad added the Framework Issues related to broader framework topics, especially as it relates to javascript label Apr 19, 2017
@youknowriad youknowriad self-assigned this Apr 19, 2017
@jasmussen
Copy link
Contributor

Yaaaaay! I love it! I will definitely give it some love and attention one of these days.

Code looks good too.

Long term we'll want it shown by default, and its state saved (so if you dismiss it, blog, then come back to the editor, the sidebar is still off until you toggle it back on). We'll want to state-save whether you're using the block editor or text editor too, on that note. Want me to create a separate ticket for this?

@youknowriad
Copy link
Contributor Author

Yes, let's create a ticket for that. We may need an API endpoint or use the settings endpoint for these settings.


&:disabled {
opacity: 0.6;
}

&.is-active {
Copy link
Member

Choose a reason for hiding this comment

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

Do we expect this to be the same styling we'll want for the :active pseudo-class ?

If so, should we add it here?
If not, should we be worried about confusion between the two unique states sharing the same name?

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 don't know? :) I've always been confused with the :active state. I think .is-active and :active are different states, maybe we should rename .is-active?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe a question for @jasmussen for prescribing variations on button state we'll need to support.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking about hover, click and active states these days, across all controls, to ensure consistency. Right now the toggled state is visually the same as :active. Did that answer the question?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means all the buttons will have the dark gray background when clicked (before releasing the mouse). I'm not sure we want this, do we?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry, I'm tired and wasn't being very clear indeed.

My mind has been thinking about the hover state, which right now is blue text and a dark gray outline, which I'm not convinced about. I've been thinking whether we could do the inverted version for both hover, active and toggled. I.e. hover would also have the dark gray background. This is in context of the accessibility and contrast discussions that took place a while back. But we might find that this feels too heavy handed, and that we might be able to have a lighter gray hover+active state, in which case only the toggled state would be dark gray.

Bottomline, probably good to not hover/active/toggled states block this PR from being merged, as this is something I will revisit across all buttons later on regardless.

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'm renaming is-active to is-toggled :)

editor/state.js Outdated
@@ -148,6 +148,15 @@ export function mode( state = 'visual', action ) {
return state;
}

export function sidebar( state = { opened: false }, action ) {
Copy link
Member

Choose a reason for hiding this comment

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

What other properties do you expect this to hold? Wondering if a simpler isSidebarOpened reducer with a boolean value might be more appropriate for now.

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 hesitated, I was expecting we may have a property saying we're showing the PostSettings or the BlockInspector, but yeah. I'll go for isSidebarOpened right now!

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call it PostInspector when the time comes. The idea being that the entire sidebar is the inspector, but when nothing is selected, you are inspecting the post itself, therefore showing the meta boxes.

.editor-sidebar {
position: fixed;
right: 0;
top: 32px + $header-height;
Copy link
Member

Choose a reason for hiding this comment

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

We'll need some breakpoint styling for this. Not sure if we wanted to do that here.

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'll leave this for a more "designy" eyes :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll definitely tackle this separately, it's already on my to-do 😉

.editor-layout.sidebar-opened .editor-layout__content {
margin-right: $sidebar-width;

.editor-text-editor__formatting {
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be nested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to be nested under .editor-layout.sidebar-opened, I can rewrite it :)

Copy link
Member

Choose a reason for hiding this comment

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

We could also define this in modes/text-editor/style.scss as assuming the existence of the ancestor modifier:

.editor-text-editor__formatting {
	// ...

	.editor-layout.is-sidebar-opened & {
		// ...
	}
}

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 just learned that we can do .editor-layout.is-sidebar-opened & And yes, this is probably better!

function Layout( { mode } ) {
function Layout( { mode, sidebarOpened } ) {
const className = classnames( 'editor-layout', {
'sidebar-opened': sidebarOpened
Copy link
Member

Choose a reason for hiding this comment

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

As a modifier class, I might expect some boolean-ish prefix to the class name, maybe has-open-sidebar ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe is-sidebar-opened to match the reducer name

Copy link
Member

Choose a reason for hiding this comment

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

or maybe is-sidebar-opened to match the reducer name

Yep, that works.

@jasmussen
Copy link
Contributor

Ticket opened in #450

@@ -4,11 +4,12 @@
import './style.scss';
import classnames from 'classnames';

function Button( { isPrimary, isLarge, className, ...additionalProps } ) {
function Button( { isPrimary, isLarge, isActive, className, ...additionalProps } ) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you intend to rename the prop from isActive to isToggled as well?

Copy link
Contributor Author

@youknowriad youknowriad Apr 19, 2017

Choose a reason for hiding this comment

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

Like I said, "too fast and miss the details" :)

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Aside from prop renaming comment, this looks good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants