Skip to content

Commit

Permalink
Initial commit - generate theme from Pattern Library.
Browse files Browse the repository at this point in the history
  • Loading branch information
alaczek committed Nov 19, 2015
1 parent 368c5f5 commit 14a8fe8
Show file tree
Hide file tree
Showing 64 changed files with 5,273 additions and 0 deletions.
56 changes: 56 additions & 0 deletions 404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* The template for displaying 404 pages (not found).
*
* @package components
*/

get_header(); ?>

<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">

<section class="error-404 not-found">
<header class="page-header">
<h1 class="page-title"><?php esc_html_e( 'Oops! That page can&rsquo;t be found.', 'components' ); ?></h1>
</header><!-- .page-header -->

<div class="page-content">
<p><?php esc_html_e( 'It looks like nothing was found at this location. Maybe try one of the links below or a search?', 'components' ); ?></p>

<?php get_search_form(); ?>

<?php the_widget( 'WP_Widget_Recent_Posts' ); ?>

<?php if ( components_categorized_blog() ) : // Only show the widget if site has multiple categories. ?>
<div class="widget widget_categories">
<h2 class="widget-title"><?php esc_html_e( 'Most Used Categories', 'components' ); ?></h2>
<ul>
<?php
wp_list_categories( array(
'orderby' => 'count',
'order' => 'DESC',
'show_count' => 1,
'title_li' => '',
'number' => 10,
) );
?>
</ul>
</div><!-- .widget -->
<?php endif; ?>

<?php
/* translators: %1$s: smiley */
$archive_content = '<p>' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', 'components' ), convert_smilies( ':)' ) ) . '</p>';
the_widget( 'WP_Widget_Archives', 'dropdown=1', "after_title=</h2>$archive_content" );
?>

<?php the_widget( 'WP_Widget_Tag_Cloud' ); ?>

</div><!-- .page-content -->
</section><!-- .error-404 -->

</main><!-- #main -->
</div><!-- #primary -->

<?php get_footer(); ?>
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[![Build Status](https://travis-ci.org/Automattic/components.svg?branch=master)](https://travis-ci.org/Automattic/components)

components
===

Hi. I'm a starter theme called `components`. I'm a theme meant for hacking so don't use me as a Parent Theme. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.

My ultra-minimal CSS might make me look like theme tartare but that means less stuff to get in your way when you're designing your awesome theme. Here are some of the other more interesting things you'll find here:

* A just right amount of lean, well-commented, modern, HTML5 templates.
* A helpful 404 template.
* A sample custom header implementation in `inc/custom-header.php` that can be activated by uncommenting one line in `functions.php` and adding the code snippet found in the comments of `inc/custom-header.php` to your `header.php` template.
* Custom template tags in `inc/template-tags.php` that keep your templates clean and neat and prevent code duplication.
* Some small tweaks in `inc/extras.php` that can improve your theming experience.
* A script at `js/navigation.js` that makes your menu a toggled dropdown on small screens (like your phone), ready for CSS artistry. It's enqueued in `functions.php`.
* 2 sample CSS layouts in `layouts/` for a sidebar on either side of your content.
* Smartly organized starter CSS in `style.css` that will help you to quickly get your design off the ground.
* Licensed under GPLv2 or later. :) Use it to make something cool.

Getting Started
---------------

If you want to keep it simple, head over to http://underscores.me and generate your `components` based theme from there. You just input the name of the theme you want to create, click the "Generate" button, and you get your ready-to-awesomize starter theme.

If you want to set things up manually, download `components` from GitHub. The first thing you want to do is copy the `components` directory and change the name to something else (like, say, `megatherium`), and then you'll need to do a five-step find and replace on the name in all the templates.

1. Search for `'components'` (inside single quotations) to capture the text domain.
2. Search for `components_` to capture all the function names.
3. Search for `Text Domain: components` in style.css.
4. Search for <code>&nbsp;components</code> (with a space before it) to capture DocBlocks.
5. Search for `components-` to capture prefixed handles.

OR

* Search for: `'components'` and replace with: `'megatherium'`
* Search for: `components_` and replace with: `megatherium_`
* Search for: `Text Domain: components` and replace with: `Text Domain: megatherium` in style.css.
* Search for: <code>&nbsp;components</code> and replace with: <code>&nbsp;Megatherium</code>
* Search for: `components-` and replace with: `megatherium-`

Then, update the stylesheet header in `style.css` and the links in `footer.php` with your own information. Next, update or delete this readme.

Now you're ready to go! The next step is easy to say, but harder to do: make an awesome WordPress theme. :)

Good luck!
52 changes: 52 additions & 0 deletions archive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* The template for displaying archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package components
*/

get_header(); ?>

<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">

<?php if ( have_posts() ) : ?>

<header class="page-header">
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
the_archive_description( '<div class="taxonomy-description">', '</div>' );
?>
</header><!-- .page-header -->

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

<?php

/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'components/content', get_post_format() );
?>

<?php endwhile; ?>

<?php the_posts_navigation(); ?>

<?php else : ?>

<?php get_template_part( 'components/content', 'none' ); ?>

<?php endif; ?>

</main><!-- #main -->
</div><!-- #primary -->


<?php get_sidebar(); ?>
<?php get_footer(); ?>
36 changes: 36 additions & 0 deletions assets/js/customizer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/

( function( $ ) {
// Site title and description.
wp.customize( 'blogname', function( value ) {
value.bind( function( to ) {
$( '.site-title a' ).text( to );
} );
} );
wp.customize( 'blogdescription', function( value ) {
value.bind( function( to ) {
$( '.site-description' ).text( to );
} );
} );
// Header text color.
wp.customize( 'header_textcolor', function( value ) {
value.bind( function( to ) {
if ( 'blank' === to ) {
$( '.site-title, .site-description' ).css( {
'clip': 'rect(1px, 1px, 1px, 1px)',
'position': 'absolute'
} );
} else {
$( '.site-title, .site-description' ).css( {
'clip': 'auto',
'color': to,
'position': 'relative'
} );
}
} );
} );
} )( jQuery );
81 changes: 81 additions & 0 deletions assets/js/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* navigation.js
*
* Handles toggling the navigation menu for small screens and enables tab
* support for dropdown menus.
*/
( function() {
var container, button, menu, links, subMenus;

container = document.getElementById( 'site-navigation' );
if ( ! container ) {
return;
}

button = container.getElementsByTagName( 'button' )[0];
if ( 'undefined' === typeof button ) {
return;
}

menu = container.getElementsByTagName( 'ul' )[0];

// Hide menu toggle button if menu is empty and return early.
if ( 'undefined' === typeof menu ) {
button.style.display = 'none';
return;
}

menu.setAttribute( 'aria-expanded', 'false' );
if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
menu.className += ' nav-menu';
}

button.onclick = function() {
if ( -1 !== container.className.indexOf( 'toggled' ) ) {
container.className = container.className.replace( ' toggled', '' );
button.setAttribute( 'aria-expanded', 'false' );
menu.setAttribute( 'aria-expanded', 'false' );
} else {
container.className += ' toggled';
button.setAttribute( 'aria-expanded', 'true' );
menu.setAttribute( 'aria-expanded', 'true' );
}
};

// Get all the link elements within the menu.
links = menu.getElementsByTagName( 'a' );
subMenus = menu.getElementsByTagName( 'ul' );

// Set menu items with submenus to aria-haspopup="true".
for ( var i = 0, len = subMenus.length; i < len; i++ ) {
subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' );
}

// Each time a menu link is focused or blurred, toggle focus.
for ( i = 0, len = links.length; i < len; i++ ) {
links[i].addEventListener( 'focus', toggleFocus, true );
links[i].addEventListener( 'blur', toggleFocus, true );
}

/**
* Sets or removes .focus class on an element.
*/
function toggleFocus() {
var self = this;

// Move up through the ancestors of the current link until we hit .nav-menu.
while ( -1 === self.className.indexOf( 'nav-menu' ) ) {

// On li elements toggle the class .focus.
if ( 'li' === self.tagName.toLowerCase() ) {
if ( -1 !== self.className.indexOf( 'focus' ) ) {
self.className = self.className.replace( ' focus', '' );
} else {
self.className += ' focus';
}
}

self = self.parentElement;
}
}
} )();
26 changes: 26 additions & 0 deletions assets/js/skip-link-focus-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
( function() {
var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1,
is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1;

if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) {
window.addEventListener( 'hashchange', function() {
var id = location.hash.substring( 1 ),
element;

if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
return;
}

element = document.getElementById( id );

if ( element ) {
if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
element.tabIndex = -1;
}

element.focus();
}
}, false );
}
})();
46 changes: 46 additions & 0 deletions assets/stylesheets/components/_gallery.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.gallery {
margin-bottom: 1.5em;
}

.gallery-item {
display: inline-block;
text-align: center;
vertical-align: top;
width: 100%;

.gallery-columns-2 & {
max-width: 50%;
}

.gallery-columns-3 & {
max-width: 33.33%;
}

.gallery-columns-4 & {
max-width: 25%;
}

.gallery-columns-5 & {
max-width: 20%;
}

.gallery-columns-6 & {
max-width: 16.66%;
}

.gallery-columns-7 & {
max-width: 14.28%;
}

.gallery-columns-8 & {
max-width: 12.5%;
}

.gallery-columns-9 & {
max-width: 11.11%;
}
}

.gallery-caption {
display: block;
}
14 changes: 14 additions & 0 deletions assets/stylesheets/components/_menu-toggle.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Small menu. */
.menu-toggle,
.main-navigation.toggled ul {
display: block;
}

@media screen and (min-width: 37.5em) {
.menu-toggle {
display: none;
}
.main-navigation ul {
display: block;
}
}
Loading

0 comments on commit 14a8fe8

Please sign in to comment.