Giter VIP home page Giter VIP logo

mythic's Introduction

Mythic

Mythic is a starter theme for WordPress.

The theme's primary goal is to offer a modern development experience for WordPress theme authors while sticking as close to possible to WordPress standards as we can. Sometimes those things don't always mesh well. This theme aims to balance that.

Requirements

There's a few requirements in order to develop a new theme or contribute back to the project:

  • PHP 5.6+ (preferably 7+).
  • Git for version control.
  • Composer for managing PHP dependencies.
  • Node 8+.
  • NPM or Yarn (your choice) for managing JS dependencies.

You should feel reasonably comfortable using the command line. The theme tries to keep this as simple as possible, but some command line knowledge is necessary in modern development.

Documentation

Check out the project wiki to learn how to install and set up the theme.

Copyright and License

Mythic is licensed under the GNU GPL, version 2 or later.

2018 © Justin Tadlock.

mythic's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mythic's Issues

viewBox is removed from SVGs

viewBox should not be removed when running npm run build. viewBox is needed for consistent styling.

Just leaving the notice here, debug later.

Tutorial and doc idea thread

Just opening this topic to keep a running list of tutorial ideas on things related to Mythic, which includes Hybrid Core and other add-ons.

  • Full tutorial on using Hybrid Breadcrumbs. (Tutorial)
  • Full tutorial on using Hybrid Carbon. (Tutorial)
  • Registering custom widgets the Mythic/OOP way. (Tutorial)
  • Cover using the build scripts in more depth.
  • Working with the Mythic\Customize\Customize class.
  • Using the hybrid-customize project.

Leave other ideas below.

before_page_number args to pagination

I was trying to add before_page_number to pagination like this:

posts_pagination( [
	'prev_text'          => __( '← Previous', 'uuups' ),
	'next_text'          => __( 'Next →', 'uuups' ),
	'title_text'         => __( 'Posts Navigation', 'uuups' ),
	'container_class'    => 'pagination pagination--posts',
	'title_class'        => 'pagination__title screen-reader-text',
	'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'uuups' ) . ' </span>',
] );

But it outputs:

<li class="pagination__item pagination__item--number"><a href="http://foxland-products.local/page/2/" class="pagination__anchor pagination__anchor--link">&lt;span class="meta-nav screen-reader-text"&gt;Page </a></li>

I'm not sure where the escaping function kicks in for &lt;span.

Establishing a standard for Gutenberg styles

It's not in the theme yet, but we need to have Gutenberg block styles ready to go out of the box.

Folder

A resources/styles/blocks folder is going to be in the theme. That's a definite. Everything else below is what we need to figure out.

Files

We could populate the blocks folder with a simple _index.scss for theme authors to get started with a completely blank slate. Or, we could add the files right off the bat.

Here's a look at most (not sure if I've got all yet) blocks and a proposed file naming system for core blocks:

/blocks
	/_wp-block-button.scss
	/_wp-block-categories.scss
	/_wp-block-code.scss
	/_wp-block-columns.scss
	/_wp-block-cover-image.scss
	/_wp-block-embed.scss
	/_wp-block-file.scss
	/_wp-block-gallery.scss
	/_wp-block-image.scss
	/_wp-block-latest-posts.scss
	/_wp-block-preformatted.scss
	/_wp-block-pullquote.scss
	/_wp-block-quote.scss
	/_wp-block-separator.scss
	/_wp-block-subhead.scss
	/_wp-block-table.scss
	/_wp-block-verse.scss

Default styles

Do we include default styles for Gutenberg? These could just be copy-pasted, essentially, from core as a base.

Mythic is 100% designed with the idea that theme authors will be building Gutenberg-ready themes. The question is how far we want to go. We have to balance between getting in the theme author's way and getting them off on the right foot.

In app/functions-assets.php, I have the code for disabling Gutenberg's default styles. This is commented out right now. Whether we uncomment will be largely dependent on whether we package any default styles.

add_action( 'enqueue_block_editor_assets', function() {

	wp_enqueue_style( 'mythic-editor', asset( 'styles/editor.css' ), null, null );

	// Unregister core block and theme styles.
	// wp_deregister_style( 'wp-core-blocks' );
	// wp_deregister_style( 'wp-core-blocks-theme' );

	// Re-register core block and theme styles when empty string. This is
	// necessary to get styles set up correctly.
	// wp_register_style( 'wp-core-blocks', '' );
	// wp_register_style( 'wp-core-blocks-theme', '' );

}, 5 );

CSS build scripts

I'm fairly certain, we'll be using npm-scripts at this point rather than something like Gulp or Grunt. I'm also fairly certain we'll default to handling SCSS or similar syntax.

The following is a rundown of some of the CSS-related build scripts that we might utilize. These were copied over from our Slack channel discussion.

What we need to do is come up with a solid set of scripts that would be useful in most theme projects.

Working with the styles:

Working with the files (probably some crossover with JS files):

redundant "allign" styles

Build system

Thus far, we've experimented with various build systems and are currently using Webpack. It's the big player in town and is something that's likely going to be used by many people who are building custom Gutenberg blocks.

With that said, we need to decide what's right for this theme.

And, I fully expect there to be forks of this theme with build systems that are suited to individual theme authors. However, I want to have a good base for the majority of theme authors who might not want to delve into all that and just needs something that works.

Defining our needs for assets

The biggest thing we've lacked is a list of actually what our needs are as theme authors to guide us each step along the way. How can we know which tools are needed if we don't clearly define what we're trying to accomplish?

CSS

CSS is the primary asset type in building WP themes. I think we have a pretty clear picture of what we want to do:

  • Write in Sass and/or next-generation CSS. transpiling
  • Bundle smaller files into one final file. bundling
  • Our code checked for errors. linting

JS

  • Write in modern JS and have it work cross-browser. transpiling
  • Bundle smaller files into one final file. bundling
  • Our code checked for errors. linting

Images and SVGs

  • Have these files cleaned up and minimized for performance.

How the process should work

The underlying tools (whether it be Webpack, Gulp, Grunt, or something else) shouldn't really matter to theme authors. The theme should define some npm-scripts commands that handle that.

For me, personally, I feel like I want the following things:

// Build everything.
npm run build

// Build only scripts|styles|images|svgs
npm run build:*

// Lint scripts|styles
npm run *:lint

// Watch
npm run watch

// Watch scripts|styles
npm run watch:*

That's a bit of a hierarchy. build handles everything below it and so on.

For those that do want to or must edit

We'll have a base of standard things. However, theme authors will inevitably need to edit something in the build process. That should be simple and not require you to jump through any hoops.

For example, if a theme author needs to add a new stylesheet to be compiled separately, they shouldn't have to import that into something else. They should have a "config" file to define it (or have it done automatically). Same thing with JS files.

That means having a clear organizational structure (I like where we're at right now with this) and having clear docs (we'll get those).

Adding travis.yml

Travis helps test and deploy code. It can run tests we specify by adding .travis.yml file. I especially find it useful when doing PRs for other projects. This is also related to PHP sniffs in #7.

Couple of examples:

Bundle command

Bundling the theme for distribution is probably the last script we need. It should be triggered from the command line like so:

npm run bundle

It should create a new folder in the theme named mythic (theme name) or simply bundle. The idea is that theme authors would want the theme prepared for distribution with only the files that need to be uploaded to the site.

The following should be included:

- changelog.md      (not in the repo yet)
- functions.php
- index.php
- license.md
- readme.md
- screenshot.png
- style.css

- /app
- /dist
- /resources
	- /lang
	- /scripts      (WordPress.org-only)
	- /styles       (WordPress.org-only)
	- /views
- /vendor

WordPress.org requires the original script/style files when minifying them. So, we'll want to have something commented out that theme authors can uncomment for those particular directories.

Wepack config

We could probably do a webpack.config.bundle.js file for this to keep it separate.

Or, if someone knows how to integrate this into the webpack.mix.js and pass in a custom variable from the scripts line in package.json, that'd work. Need something like:

if ( bundle ) {
	mix.copy()...
}

This should be pretty basic. We just need to let theme authors edit what files they might want to include and copy them all over with the bundle command.

Production?

@justintadlock

I love the direction this theme is going. I realize it is under very active development right now, but do you have an idea of when you think it would be stable enough for production use?

I'd like to take my first stab at developing with the "hybrid suite" and I'm not sure what direction to go in terms of the starter themes you've developed.

Thanks so much!

Explore switching to Webpack-only instead of Mix

I initially decided upon Laravel Mix because it was something that most of our primary group of devs agreed upon as a solid solution. It didn't have everything that everyone wanted, but it had enough for us to compromise and close out months of discussion over a build system. This was one of the biggest hurdles for even getting Mythic launched.

While Mix does everything I personally need at the moment, I believe moving to a Webpack-only solution would be beneficial in the long run because it would help developers become more familiar with the underlying technology. Mix is a layer on top of Webpack, which can sometimes hide what's going on. In some cases, that can make it harder to do things.

And, we're still waiting for Mix to catch up with the latest improvements (particularly speed improvements) in newer versions of Webpack.

I'm not convinced we need to change right away. However, I do want to open this ticket so that we can explore this option for version 2.0 or so. Or, at the very least, have some examples for others who want to go down that path for themselves in the meantime.

Right now, I'd love to see others' Webpack-only implementations.

Add default smiley and emoji styles

In version 5.0 of Hybrid Core, we no longer provide stylesheets. Therefore, we're missing the default styles for smileys and emojis.

Here's a look at the core styles that HC removes. We need to provide these (minus all the !important bits) in /resources/scss/utilities.

img.wp-smiley,
img.emoji {
    display: inline !important;
    border: none !important;
    box-shadow: none !important;
    height: 1em !important;
    width: 1em !important;
    margin: 0 .07em !important;
    vertical-align: -0.1em !important;
    background: none !important;
    padding: 0 !important;
}

Getting ready for Gutenberg

In my opinion starter theme should support up coming editor, code name Gutenberg. For me support means:

  • Theme support for align-wide.
  • Theme support for editor-color-palette.
  • Dequeue Core block styles from front-end.
  • Adding styles for blocks that needs it. For example <hr>, <tables>, and <blockquote> already have styles.
  • Enqueue block related styles back to editor.
  • Trying to have system that allows easily adding styles for custom blocks (from public or private plugins).

For organising SASS/CSS I'm thinking that there should be blocks.css imported automatically from SASS files. Then this file can be enqueued in the editor.

blocks.css could have:

  • All html elements like <table>, <hr> etc.
  • Typography.
  • All wp-block-* related styles like for wp-block-button.

These styles might need to be wrapped inside .edit-post-visual-editorclass but this can change.

Description markup is show even if it's empty

Current markup: <div class="app-header__description"><?php bloginfo( 'description' ) ?></div>.

Should we roll a template function for this so that description is only shown when there is one. Similar to Underscores.

I was thinking template function if we wan't to avoid if else as much as possible in template files.

New architecture?

I see you are using new architectual approaches. What are your reasons behind them? Are you going to elaborate on them somewhere/sometime?

I'm enthousiastic to see this in a WordPress theme and I'm curious to learn more about it. It's good to see some evolvement in theme development.

Setting some base CSS values and variables

Because we decided that adding baseline Gutenberg styles into theme was a good idea, we also need to take care of some baseline width, margin, padding, size, and similar values.

For example, take this code from resources/scss/blocks/core/_cover-image.scss:

.wp-block-cover-image-text {
	color:         color( white );
	font-size:     2em;
	line-height:   1.25;
	z-index:       1;
	margin-bottom: 0;
	max-width:     content-width();
	padding:       14px;
	text-align:    center;

	a,
	a:hover,
	a:focus,
	a:active {
		color: color( white );
	}
}

As you can see, the content-width() function will return the theme's content width. However, we should take that further and allow theme authors to plug in other numeric values in /resources/scss/settings. The font-size, line-height and padding values from above could all be replaced with settings.

To do this, we'd need to identify all the places that could use such treatment and establish some standards on how to best handle that.

We could even explore existing packages/libraries that are out there.

Should we dump autoload after theme rename?

When running the rename command, the Mythic namespace is replaced with the theme's new namespace in composer.json. This means that composer dump-autoload needs to be called to regenerate the autoload files.

I've added this extra step to the installation docs.

One proposed solution was to change the rename script in package.json to this:

"scripts": {
	"rename": "theme-claim && composer dump-autoload"
}

My worry with this is that on some setups the composer command is composer.phar.

Perhaps we should just leave it be and keep this in the installation docs. Opening this ticket for discussion.

WordPress.org readme.txt

After today, WordPress.org will start requiring a readme.txt for themes submitted to the directory. This is for, with any luck, the theme directory behaving a little more like the plugin directory at some point in the future.

Mythic itself mostly tries to be .ORG-compliant with a couple of notable exceptions.

If we do add it, we'll want to build out a basic outline to get theme authors started. If we don't add it, we should note it in the docs.

I don't feel particularly strongly either way about it. I could see it being a nuisance if the majority of folks using Mythic aren't submitting to the directory and end up deleting the file.

CSS variables being output twice

When using CSS variables in Mythic .scss files, the var() declaration is being output twice. I narrowed this down to PostCSS. I wasn't able to alter the behavior via PostCSS config in the mix file.

At Marty's suggestion, I updated the required version of postcss-preset-env in the Mythic package.json file as follows:

"postcss-preset-env": "^6.4.0"

This fixed the issue of duplicate declarations in the CSS output, and should be the default.

Use an _index.scss for /styles/* subfolders

One thing I've been considering is adding an _index.scss file to each of the subfolders under /resources/styles.

For example, a /components/_index.scss would import all of the other .scss files from /components. Then, in /resources/styles/screen.scss (or elsewhere), we could simply import them all with one line of code:

@import 'components/index';

Anyone see any potential downsides to this? Or, alternative solutions?

Edit: This could potentially be an __index.scss (double underscore) file too to put it at the top of the file list.

SVG system

SVG system may or may not be good fit for this project. If you ask me, it is:) I can't remember the last time when SVGs wasn't involved in a project.

What SVG system can mean:

  • get_svg() function or similar to injecting SVG icon markup in the template files.
  • Social menu links using SVG icons.
  • Build tools that minify SVG icons into single SVG sprite file.
  • Example file in Foxer.

Integrating the WPThemeReview coding standards

Now that version 0.1.0 of the WPThemeReview project has been tagged, it's time to start discussing adding this to Mythic.

The goal has always been for this to be the default standards shipped with the theme. The timing just wasn't there when we shipped 1.0.0 of Mythic.

They have instructions to follow, so this should be fairly straightforward: https://github.com/WPTRT/WPThemeReview#installing-wpthemereview-as-a-project-dependency

We have a couple of options:

  1. Install this as a dependency (as well as dealerdirect/phpcodesniffer-composer-installer, which is required).
  2. Create a separate coding standards repository/package, which can be managed separately.

It'll probably be better to start with option #1 and move to option #2 if things evolve.

Browsersync improvements

I think it would be nice to add browsersync proxy option into npm run rename or to some other install instruction. Currently it's hardcoded inside webpack.mix.js file as localhost. But usually developers has different local domain for projects

Also I didn't understand why changing css and js files from dist folder has been omitted in browsersync file extensions. Maybe it has some reason?

cleanup in webpack.mix

To make simpler to change the resources/ directory, we should probably use a variable so it only needs changed in one location.
Finding and replacing resources/ is error prone because that name also exists here vendor/justintadlock/hybrid-core/src/resources/

Found some lonely "double quotes" here https://github.com/justintadlock/abc/blob/master/webpack.mix.js#L149-L151
Also causes problems when doing a find and replace. Should make those consistent.

SASS / CSS structure

We have already talked about how crucial good SASS structure is. It's the foundation where big projects can also build upon without losing mind.

Suggested methods are ITCSS and BEM. There is already basic folder structure for it.

Next step is to figure out what to put in which folders. I'll try to work on this and write more ideas this week.

Couple of references:

Text domain missing

Just adding this for reminder. Text domain is missing from strings: __( 'Next &rarr;' ).

New cover image/video classes

So not too offend videos, -image was removed from all the class selectors related to the "cover" block.
Now it's just .wp-block-cover and .wp-block-cover-text.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.