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

Chrome: Rearrange the preview button in the header #845

Merged
merged 3 commits into from
May 24, 2017

Conversation

youknowriad
Copy link
Contributor

closes #818

This PR tries to match the design in #818 (comment)

I also disabled the "preview" button when the post is not saved yet.

@youknowriad youknowriad added the General Interface Parts of the UI which don't fall neatly under other labels. label May 19, 2017
@youknowriad youknowriad self-assigned this May 19, 2017
@youknowriad youknowriad requested a review from jasmussen May 19, 2017 14:20
@youknowriad youknowriad force-pushed the update/rearange-header-preview branch from 7d98816 to 3978632 Compare May 19, 2017 14:21
@aduth
Copy link
Member

aduth commented May 19, 2017

I also disabled the "preview" button when the post is not saved yet.

Can you explain this?

<Button href={ link } target="_blank">
<Dashicon icon="visibility" />
<IconButton
href={ !! link ? link : undefined }
Copy link
Member

Choose a reason for hiding this comment

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

Was there a case where link was not undefined but not intended to be used as the href to prompt this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I disable the button, the link is equal to "" which triggers a a and the pseudo-class disabled don't work on links.

@jasmussen
Copy link
Contributor

Visually I think this is great!

Re: preview button being disabled — I don't have strong opinions, but I'm leaning towards us emulating the behavior in wp-admin currently, which is that you can preview even a completely empty post that hasn't even been saved yet. You won't see much, because there isn't anything to see, but that is what should be expected I suppose.

@youknowriad
Copy link
Contributor Author

Preview disabled

Yes, this is temporary and I think we should do the same thing as the current wp-admin behaviour, Thought, I don't know how this works, I need details here. If the post is not saved yet, should I save it as a "draft" before opening the preview link.

I don't think we have the API that allows us to save a revision or a post just to preview (like wp-admin does).

@jasmussen
Copy link
Contributor

Yes, this is temporary and I think we should do the same thing as the current wp-admin behaviour, Thought, I don't know how this works, I need details here. If the post is not saved yet, should I save it as a "draft" before opening the preview link.

Current behavior is that if a post isn't even saved, then it 404s on the frontend. Which is fine, because it doesn't exist yet :)

@youknowriad
Copy link
Contributor Author

Current behavior is that if a post isn't even saved, then it 404s on the frontend. Which is fine, because it doesn't exist yet :)

This is not always true, if you type anything in the title/content, you'll see the post even if it's unsaved.

@jasmussen
Copy link
Contributor

This is not always true, if you type anything in the title/content, you'll see the post even if it's unsaved.

Interesting. Well, in any case I'd defer to the simplest possible implementation, code wise, at this point.

@aduth
Copy link
Member

aduth commented May 23, 2017

Thought, I don't know how this works, I need details here. If the post is not saved yet, should I save it as a "draft" before opening the preview link.

Yes, but not exactly in this order aince opening a new tab must occur in response to a user action (e.g. click), so cannot be delayed to wait for the save to complete. Instead, we'd open a new tab with about:blank, save the post, then when the save completes, replace the tab's window reference location with the URL of the saved post. We do this in Calypso, though I'm not fond of its use of callbacks (source).

We can defer this to a later pull request.

@@ -75,7 +75,10 @@ class Inserter extends wp.element.Component {
onClick={ this.toggle }
className="editor-inserter__toggle"
aria-haspopup="true"
aria-expanded={ opened ? 'true' : 'false' } />
aria-expanded={ opened ? 'true' : 'false' }
Copy link
Member

Choose a reason for hiding this comment

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

Not specific to the scope of this pull request, but I wonder if React is smart enough to handle the boolean value without the ternary expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried this and yes, React handles the boolean correctly. updating

@youknowriad youknowriad merged commit 132110f into master May 24, 2017
@youknowriad youknowriad deleted the update/rearange-header-preview branch May 24, 2017 11:04
@jasmussen
Copy link
Contributor

Yaaazzz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview button behavior
3 participants