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

Themes: Add themes detail page #3053

Merged
merged 2 commits into from
Feb 15, 2016
Merged

Themes: Add themes detail page #3053

merged 2 commits into from
Feb 15, 2016

Conversation

ehg
Copy link
Member

@ehg ehg commented Feb 3, 2016

Implements part of #2875 & #2876

This PR deals with setting up a /themes/[x] route, which will eventually contain details about the theme. We're only concerned with showing a fake, static title, real data comes later.

Notes:

  • Due to the way routing and layout currently works, i.e. two layout trees, not isomorphic, there are some hacks here to get SSR working properly. I've inline commented them.
  • isFullScreen layout prop introduced, so we can get rid of borders/margins/padding.

TODO:

  • Find a better name for isFullScreen
  • Reduce crazy shrinkwrap diff
  • Factor out the renderToString business

To test:

  • Try /design and click on a theme's menu, and choose details
  • Try logged in and logged out
  • Make sure navigation works as intended

Current UI state:
screen shot 2016-02-15 at 16 43 06
screen shot 2016-02-15 at 16 46 02

@ehg ehg added [Feature Group] Appearance & Themes Features related to the appearance of sites. [Status] In Progress labels Feb 3, 2016
@ehg ehg self-assigned this Feb 3, 2016
@ehg ehg added this to the Themes: Showcase M4-ThemeSheets milestone Feb 3, 2016
@ehg
Copy link
Member Author

ehg commented Feb 4, 2016

@mcsf — the routing bits here could inform #3065

@mcsf
Copy link
Member

mcsf commented Feb 4, 2016

@mcsf — the routing bits here could inform #3065

👍

@ockham
Copy link
Contributor

ockham commented Feb 4, 2016

Possible that you didn't add my-sites/themes/sheet.jsx to this branch yet?

@ockham
Copy link
Contributor

ockham commented Feb 4, 2016

BTW, I just added a ThemeDetailsData fetcher component to #3011 :-)

@ockham
Copy link
Contributor

ockham commented Feb 5, 2016

Feature flag it?


console.log( 'running ze details controller' );

if ( true ) { // bail if we're logged out
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing this to if ( user ) gets rid of the replacement error

@ehg ehg force-pushed the add/themes-sub-bar branch from c5e3345 to b619f61 Compare February 9, 2016 17:37
@ehg
Copy link
Member Author

ehg commented Feb 9, 2016

Rebased against master.

Getting replaced root warnings when logged out and going from /themes/x to /design. Messy.

screen shot 2016-02-09 at 17 37 28

@seear
Copy link
Contributor

seear commented Feb 9, 2016

Getting replaced root warnings when logged out and going from /themes/x to /design. Messy.

How are you doing this? Back button? Address bar? Both fine for me.

@ehg
Copy link
Member Author

ehg commented Feb 10, 2016

How are you doing this? Back button? Address bar? Both fine for me.

Direct hit on /themes/x, then pressing the back button.

.filter( r => r.match !== null );


if ( matchedRoutes.length ) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is our own mini-router. We need to do this before the layout is rendered.

@ehg ehg force-pushed the add/themes-sub-bar branch 2 times, most recently from 625d8d0 to 868de4e Compare February 10, 2016 19:52
@ehg
Copy link
Member Author

ehg commented Feb 10, 2016

In the spirit of @mcsf's routing PR, I extracted the renderToString logic into its own module, and switched to using an unbounded lodash memoize for caching: 868de4e

@ehg ehg added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Feb 10, 2016
@ehg ehg force-pushed the add/themes-sub-bar branch from 868de4e to 0dad4f9 Compare February 10, 2016 20:14
@seear seear force-pushed the add/themes-sub-bar branch from e588710 to 5fbd76f Compare February 12, 2016 14:12
@ockham
Copy link
Contributor

ockham commented Feb 15, 2016

I'd love if we combined the theme sheet with the routing from #3207.

Rationale -- I'd really like to avoid introducing new special cases that are spread over a couple of files, specifically

  • the mini-router in client/boot
  • making LayoutLoggedOutDesign even more particular to our routes, when I think it could be made quite generic relatively easy from its current state in master
  • the need to unmount secondary in the details route (this might be my most convincing argument)

I think we'll only need a couple of changes to server/pages on top of #3207 to make this work in a generic enough way (stealing some bits from this PR :] ) I'll try to come up with a PoC PR.

@ockham ockham mentioned this pull request Feb 15, 2016
@ockham
Copy link
Contributor

ockham commented Feb 15, 2016

-> #3302

@ehg ehg force-pushed the add/themes-sub-bar branch from 5fbd76f to 797cf2b Compare February 15, 2016 12:35
@seear
Copy link
Contributor

seear commented Feb 15, 2016

I would rather see this PR merged sooner rather than later, since it is harder to build on top of while it is out on a branch. For example, it makes it hard to see the (pretty small) changes involved in #3279. Removing the ugly hacks later will be the payoff from the routing work.

*/
import config from 'config';

const memoizedRenderToString = memoize( ReactDomServer.renderToString, element => JSON.stringify( element ) );
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 assume that any data retrieval has to happen outside of the renderToSting call, because there will always be some async component to it. Does that we are caching a call here that actually does very little, giving us an extra layer of cache alongside the data cache that may not save any time?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have a data cache at the moment, though. I'd prefer some kind of caching that we could always remove later. Also, themes data isn't hugely variable, so I believe there will be some benefit to caching the markup — especially if we can share the markup between node instances.

@ehg
Copy link
Member Author

ehg commented Feb 15, 2016

I would rather see this PR merged sooner rather than later, since it is harder to build on top of while it is out on a branch.

OK, so should I split this into multiple PRs? e.g. render module, routing hacks & theme sheet component?


const themesRoutes = [
{ name: 'design', path: new Path( '/design' ) },
{ name: 'themes', path: new Path( '/themes/:theme_slug' ) },
Copy link
Contributor

Choose a reason for hiding this comment

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

Feature check here maybe?

@seear
Copy link
Contributor

seear commented Feb 15, 2016

There are some layout problems for the rest of the site, even with the feature-flag turned off.

screen shot 2016-02-15 at 16 24 03

@seear
Copy link
Contributor

seear commented Feb 15, 2016

Ok, looking good now. Ready to merge 👍


.themes__sheet-bar
{
background-color: #0087be;
Copy link
Contributor

Choose a reason for hiding this comment

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

$blue-wordpress instead of hard coded color. :)

@seear
Copy link
Contributor

seear commented Feb 15, 2016

(don't forget to squash...)

ehg added 2 commits February 15, 2016 17:09
- add an isFullScreen option to layouts ( gets rid of side margins )
- unmount sidebar for sheet view
- set no masterbar border for fullscreen mode
- implement a pre-layout router, that will be gone as soon as we have an
  isomorphic, single render tree layout solution. which is soon!
- factor out renderToString into render module
- use memoize, resolve by JSON.stringify( element ), use LruMap to
  make sure cache isn't unbounded
@ehg ehg force-pushed the add/themes-sub-bar branch from 77ba955 to 1f05fee Compare February 15, 2016 17:10
ehg added a commit that referenced this pull request Feb 15, 2016
@ehg ehg merged commit 13f458b into master Feb 15, 2016
@ehg ehg deleted the add/themes-sub-bar branch February 15, 2016 17:20
@ehg ehg removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 15, 2016
@ehg ehg restored the add/themes-sub-bar branch February 15, 2016 17:25
@ehg ehg mentioned this pull request Feb 15, 2016
6 tasks
props = { routeName: matchedRoutes[0].name, match: matchedRoutes[0].match };
Layout = require( 'layout/logged-out-design' );
}
} else if ( startsWith( '/design', window.location.pathname ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the wrong arg order? cf L188 and https://lodash.com/docs#startsWith

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah, yes. Why does it work?!

Copy link
Contributor

Choose a reason for hiding this comment

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

Cause this is only for logged-out, where we don't care for single sites. Then again, we should check if it breaks tiers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #3374 to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Appearance & Themes Features related to the appearance of sites.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants