A photo portfolio theme with React and WordPress.
The old inu.ro design is dated back spring 2014. It's time for a refresh.
The slider on mobile screens was confusing: on click the slide disappeared and the next photo was sliding in. This had to be fixed.
- Keep the same simple design.
- Keep the black/white background switcher.
- Fix the slider on mobile screens.
- Add a random slideshow.
- Make categories display order changeable on the backend.
- Keep the WordPress backend.
- Refresh the front-end stack and make it future friendly for another couple of years.
- Enhance page load performance.
- The new site: http://inu.ro
- The source code: https://github.com/metamn/inu-v2-b
- The styleguide: http://inu.ro/styleguide
- The component guide and the API documentation: http://metamn.io/inu-v2-b/
- A blog post: http://metamn.io/react/thoughts-on-react-after-the-first-commercial-project/
The following features were added:
- WordPress updated to Gutenberg.
- Category Order and Taxonomy Terms Order plugin added.
- Support for multiple ways to add photos:
- As a featured image.
- Inserted into the post.
- As associated media to the post.
- React Single Page Application with function components and hooks.
- WordPress theming with create-react-wptheme
- GraphQL with WP GraphQL and @apollo/react-hooks
- styled-components for styling.
- Prop types for static type checking.
- Query fragments.
- Complete API/JSDoc documentation.
-
Component based design with Storybook.
-
Design documentation with a custom made styleguide.
-
New technologies wherever possible:
CSS Grid
layoutCSS scroll-snap
for sliding images inspired by Google Developers
A short overview of the major steps and tasks done. It is completely based on Thinking in React with each step separated into a feature branch. Every branch goes into deeper details in its README.md.
Mocks - v0.0.1
- Mocking up the component structure and the functionality
- Adjusting component structure to the WP GraphQL API
- Applying the single responsibility principle
- Create requirement specification
Static content (a.k.a data)- v0.0.2
- Building up the data components.
- Continuing with other (presentational) components.
- Creating additional components when necessary. Like
MenuItem
forMenu
. - Focusing on content and data. Any new ideas are added as Github Issues to be implemented later.
Interaction - v0.0.3
- Going through each component which is handling interactive elements and implement their functionality. Usually with states.
- Connect states together and lifting state up.
Refactoring - v0.0.4
- Make sure all components satisfy the Single Responsibility Principle (SRP).
- Separate reusable components (for web, for WordPress) from project specific components.
Theme - v0.0.5
- Presentational (reusable web) components should be semantically valid in the W3C checker.
- Container (non-reusable, project specific) components which holds the business logic should be fragments. This way the
divism
is highly reduced and the layout can be easily sketched with CSS Grid. - All elements should be aligned to the typographic grid both vertically and horizontally.
Performance - v0.0.6
- Database queries were lifted up to the highest level. This way the minimum amount of queries are performed only.
- A new slider had to be added. The old slider triggered too many re-renders.
Best practices checklist - v0.0.7
- Testing the dev version only. After deployment the live (staging) site will be more thoroughly tested.
Documentation - v0.0.8
- Developer docs created (this README.md).
- Components documented with Storybook.
- API documented with JSDoc, JSDoc2Markdown and added to Storybook as Notes.
- Theme / style / design decisions documented with a handmade styleguide.
Live Test - v0.0.9
- Testing live on multiple devices and browsers.
| Device / OS | iOS *| Android *| Ubuntu *| Windows *| MacOS *|
---------------------------------------------------------------
| Phone | [1] | π | n/a | n/a | n/a |
| Tablet | [1] | π | n/a | n/a | n/a |
| Desktop | n/a | n/a | π | [2] | ... |
[1] The slider flicks on touch scroll. This is an [official bug](https://github.com/metamn/inu-v2-b/issues/24)
[2] Doesn't works at all in Internet Explorer.
π Works in:
* iOS browsers: Safari
* Android browsers: Chrome
* Ubuntu browsers: Firefox, Chrome, Opera
* Windows browsers: Chrome, Firefox, Edge
- Re-testing for best practices.
See screenshots below with results.
Performance - v0.1.2
Implement best practices (continuously collected) to enhance performance. Such:
-
Wrap all business logic into a
UseEffect
-
Wrap expensive function calls into
useMemo
-
Stress-test the whole app: https://overreacted.io/writing-resilient-components/#principle-3-no-component-is-a-singleton
-
Avoid making a local state global: https://overreacted.io/writing-resilient-components/#principle-4-keep-the-local-state-isolated
-
Reduce re-renders
Couldn't manage it. All examples 1 2 are using the async / axios way which isn't compatible with the useQuery
approach from Apollo where a loading
result is immediately returned - which cannot be memoized, set as state etc ...
Still to research ... the solution lies somewhere in apolloClient
/ <ApolloProvider>
- Suspense
The functionality is already implemented either by displaying default data (Site info, Categories) or with the fade in technique (Content) and works pretty well ...
- Safari / iOS scroll bug: #24
All changes to the project are documented here using the Keep a Changelog format and semantic versioning.
- A few memoizations where they were appropiate.
react-apollo-hooks
to@apollo/react-hooks
- Grouping images into '/images'. See #31
- Storybook issue #26
This is the first official release.