GithubHelp home page GithubHelp logo

flyntwp / flynt-starter-theme Goto Github PK

View Code? Open in Web Editor NEW
69.0 10.0 4.0 15.27 MB

The starter theme for building Flynt projects.

License: MIT License

PHP 56.41% HTML 5.28% CSS 13.13% JavaScript 25.18%
wordpress wordpress-theme wordpress-starter-theme wordpress-development wordpress-developer-theme wordpress-boilerplate flynt-framework wordpress-framework jeet webpack

flynt-starter-theme's Introduction

flynt-starter-theme

standard-readme compliant Build Status Code Quality

The starter theme for building Flynt projects.

⚠️ DEPRECATED. This repository is no longer in active development. For the latest version of Flynt please use the new Flynt repository. ⚠️

Table of Contents

Background

Flynt is a sustainable approach to website development and content management with a component-based philosophy.

Flynt Theme is a ready-to-go WordPress theme that implements all of Flynt's best practices.

Install

  1. Install Node.
  2. Install Yarn.
  3. Create a new project folder and setup a new WordPress installation.
  4. Install and activate the following plugins:
  1. Clone the flynt-starter-theme repo to <your-project>/wp-content/themes.
  2. Change the host variable in flynt-starter-theme/gulpfile.js/config.js to match your host URL.
const host = 'your-host-url.test'
  1. In your terminal, navigate to <your-project>/wp-content/themes/flynt-starter-theme. Run yarn and then yarn build.
  2. Go to the administrator back-end of your WordPress site and activate the flynt-starter-theme theme.

Usage

In your terminal, navigate to <your-project>/wp-content/themes/flynt-starter-theme and run yarn start. This will start a local server at localhost:3000.

Changes to files made in Components and Features will now be watched for changes and compiled to the dist folder.

Configuring Page Templates

All template files can be found under the theme root, in the templates directory.

The structure of each page within the theme is created using a nested JSON object. Each PHP template within the templates directory takes a simple JSON configuration file, and using the Flynt Core plugin, parses and renders this into HTML.

For example, take templates/page.php:

<?php

Flynt\echoHtmlFromConfigFile('default.json');

The JSON template configuration files are found in config/templates. These configuration files define the components and their areas which are loaded into the template.

Take config/templates/default.json as an example. This template contains the DocumentDefault component, with one area within it: layout. The layout area contains the LayoutSinglePost component, which in turn has three nested areas: mainHeader, pageComponents, and mainFooter. In addition, the pageComponents area contains the ComponentLoaderFlexible component.

{
  "name": "DocumentDefault",
  "areas": {
    "layout": [
      {
        "name": "LayoutSinglePost",
        "areas": {
          "mainHeader": [],
          "pageComponents": [
            {
              "name": "ComponentLoaderFlexible",
              "customData": {
                "fieldGroup": "pageComponents"
              }
            }
          ],
          "mainFooter": []
        }
      }
    ]
  }
}

The layout area is then rendered in the Components/DocumentDefault/index.twig template:

<!DOCTYPE html>
<html class="flyntComponent {{ body_class }}" lang="{{ site.language }}" dir="{{ dir }}" is="flynt-document-default">
  <head><!--...--></head>
  <body role="document">
    {{ area('layout') }}
    {{ wp_footer }}
  </body>
</html>

Components

A component is a self-contained building-block. As such, each component is kept within its own folder which contains everything it requires; the layout, the ACF field setup, all necessary WordPress filter and hook logic, scripting, styles, and images.

  ExampleComponent/
  ├── assets/
  |   ├── exampleImage.jpg
  |   └── exampleIcon.svg
  ├── fields.json
  ├── functions.php
  ├── index.twig
  ├── README.md
  ├── script.js
  ├── style.styl

Building components is a sustainable process, meaning every component you develop can be reused within a project, or in another; increasing your head-start with every new Flynt project.

Areas

Since components are self-contained, areas provide a way to stack our building-blocks together. An area is simply a location within a component where it is possible to add other components.

Features

With WordPress, it is easy to create one large functions.php file, crammed full of all the custom logic your theme may need. This can get messy. In Flynt, we split each piece of functionality into smaller, self-contained feature bundles.

In most cases, features add global hooks and filters that affect the project on a global level. With this in mind, each feature is built with reusability in mind.

Flynt comes with a core set of ready to go features, each with its own readme. To learn more, look through the Features directory.

Theme Structure

flynt-starter-theme/             # → Root of the theme
├── Components/                  # → All base components
├── config/                      # → WP/ACF Configuration
│   ├── customPostTypes/         # → Configure custom post types
│   ├── fieldGroups/             # → Configure ACF field groups
│   ├── templates/               # → Page templates (JSON)
├── dist/                        # → Built theme files (never edit)
├── Features/                    # → All features
├── gulpfile.js/                 # → Gulp tasks and setup
│   ├── tasks/                   # → Individual gulp-tasks, e.g. webpack, stylus
│   ├── config.js                # → Gulp config
│   ├── index.js                 # → Load gulp tasks with config
│   ├── webpack.config.js        # → Webpack config
├── lib/                         # → Hold utils and setup features
│   ├── Utils/                   # → Small utility functions
│   ├── Bootstrap.php            # → Flynt Bootstrap
│   ├── Init.php                 # → Setup theme, register features
├── node_modules/                # → Node.js packages (never edit)
├── templates/                   # → Page templates (PHP)
├── .gitignore                   # → Files/Folders that will not be committed to Git.
├── .stylintrc                   # → Define Stylus linting rules
├── functions.php                # → Set template directory and load lib/Init.php
├── index.php                    # → Theme entry point (never edit)
├── package.json                 # → Node.js dependencies and scripts
├── phpcs.ruleset.xml            # → Define PHP linting rules
├── screenshot.png               # → Theme screenshot for WP admin
├── style.css                    # → Required WordPress theme style file.
├── yarn.lock                    # → Yarn lock file (never edit)

You can read the full documentation here.

Maintainers

This project is maintained by bleech.

The main people in charge of this repo are:

Contribute

To contribute, please use GitHub issues. Pull requests are accepted. Please also take a moment to read the Contributing Guidelines and Code of Conduct.

If editing the README, please conform to the standard-readme specification.

License

MIT © bleech

flynt-starter-theme's People

Contributors

berdeb avatar biozed avatar domtra avatar emcarru avatar lukashfmn avatar usingthesystem avatar vandebled avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flynt-starter-theme's Issues

$placeholder-color mixin doesn't do anything

https://github.com/bleech/wp-starter-theme/blob/master/Components/MainLayout/BaseStyles/Mixins/helpers.styl

  • It just sets the placeholder color to white and the focus opacity to .5?
  • For some reason it doesn't seem to actually do anything unless you separate out each selector. (Stylus thing or I am just using it wrong?)
  • Also saw some comments that on Edge it should be ::-ms-input-placeholder (with a double colon). I still need to test this.
  • Personally using the following as the replacement for now:
formFieldsPlaceholder()
  input::-webkit-input-placeholder,
  textarea::-webkit-input-placeholder
    {block}

  input:-moz-placeholder,
  textarea:-moz-placeholder
    {block}

  input::-moz-placeholder,
  textarea::-moz-placeholder
    {block}

  input:-ms-input-placeholder,
  textarea:-ms-input-placeholder
    {block}

Stylus Autoprefixer

done in timowopp project, needs to be adjusted (check stylus-autoprefixer) and added as a PR

BaseComponent/MainLayout [Optimization]

Todo

  • Add role="document" to body tag
  • Remove MainHeader area
  • Implement Touch Icons and important Meta tags for all devices and operation systems
  • Check HTML5 Validation
  • Check what meta-tags and meta informations we could add to the backend configuration (favicon, touchicons, chrome colortheme hexcode etc.)
  • Check if BaseStyles should be moved into a seperate folder
    • Explanation: If you have two MainTemplates with the same style, but only the buttons are different for example, you would have to copy the whole BaseStyle folder into the MainLayout2 module just to have the same basestyle.
  • Add Title Tag

Related Tickets


Related Pull Requests

Add Rupture Definitions to Base-Style files

Currently rupture definitions are missing in

_typography.styl
_buttons.styl
_layout.styl
_forms.styl

that means, these files are using a completely different rupture scale, then the rest of the project.

BaseComponent/ContactMap [Development]

Contact Map

Requirements / Notes

  • Reference modules:
  • Use Google Maps API.
  • Could use "map" field type from ACF; then we do not need lat/long fields.
  • Could generate the google map link so that the user doesn't need to enter it.
  • Easy to add custom styling to map.
  • Ability to add content into the pin area.

User Stories

  • As an editor I can select the pin location by typing the address into a search box.
  • As an editor I can upload my pin image in one place, as a global option (for all maps).
  • As a developer I can easily extend this module to support multiple locations on one map.
  • As a developer I can easily add custom map styling. (adding some comment indication where to start some common use cases for styling)

ACF Location field type requires valid Google Maps API key to work

Maybe we could make it easy to pass this api key into the ACF feature from init.php? Right now in my project I just added a file GoogleMap.php in the ACF feature with this in it:

<?php
namespace Flynt\Features\Acf;

add_filter('acf/fields/google_map/api', function ($api) {
  $api['key'] = 'my-key';
  return $api;
});

ListPosts Component: default behavior

We should maybe discuss the default behavior that the ListPostcomponent should have.
Since the password protection concept is integrated, shouldn't we also hide private posts? Also should the password protected posts show up in the list?
What about the sticky posts?
Should all these concepts be integrated, or do they have to be integrated by project when they are needed?

BaseComponent/Oembed [Refactoring]

  • Get rid of the default poster image and make the video image required
  • Refactor the readme file
  • Check the styling and refactor it (also poster image)

Cannot save field data when changing field casing after initial creation

How to duplicate:

  1. Make a module with a text field with the name "Item".
  2. Add the module to a page, enter some dummy text to the "Item" field & hit save.
  3. Change the field name to "item".
  4. Go back to the page and try to re-add your dummy text to the "item" field- after hitting "update" the page will refresh and the data will be gone again.

Features: Order problem

Trying to access a CustomPostType options field (globalOptions) inside a component, figured out it was not working.
This caused by the action hook change on Features/CustomPostTypes/functions.php, from Flynt/afterRegisterFeatures to init.
Fixed it temporarily by adding a low priority to the init action hook of the GoogleAnalytics Feature:
add_action('init', 'Flynt\Features\GoogleAnalytics\init', 100);

Assigning Component Field Layouts to Option Pages only works alphabetical order

I tried to create an OptionPage in the Component LayoutMultiplePosts which contains a flexible content containing the Field Layouts

{
  "translatableOptions": [
    {
      "label": "Page Components",
      "name": "pageComponents",
      "type": "flexible_content",
      "button_label": "Add Component",
      "layouts": [
        "Flynt/Components/SectionContentColumns/Fields/Layout",
        "Flynt/Components/SectionContentSidebar/Fields/Layout",
        "Flynt/Components/SectionFullwidth/Fields/Layout"
      ]
    }
  ]
}

ACF currently doesn't know about the Field Layouts of the specified components, because the LayoutMultiplePosts comes first in alphabetical order.

That means, while loading the OptionPages for LayoutMultiplePosts, the Fields for every Component coming afterwards are not loaded and accessible.

Components coming before the letter L are working fine.

Posts password protection logic broken

The archive page uses the LayoutMultiplePosts layout and the ListsPosts component.
https://github.com/flyntwp/flynt-starter-theme/blob/master/config/templates/archive.json

If the first post of my list is password protected, then the whole archive page shows the password protection form.
This is caused by the LayoutMultiplePosts component, in functions.php inside the getPasswordContext: the $postId is null, therefor the function post_password_required returns true because $post = get_post($post); with an null $post returns the first post of the page (my protected post)
https://developer.wordpress.org/reference/functions/post_password_required/

Component: Cannot enqueue external style

What I input:

add_action('wp_enqueue_scripts', function () {
  Component::enqueueAssets('MainLayout', [
    [
      'name' => 'google-fonts',
      'path' => 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700|Source+Sans+Pro:300,400,600,700',
      'type' => 'style'
    ]
  ]);
});

What I get:

<link rel="stylesheet" href="http://website.dev/app/themes/website/dist/https://fonts.googleapis.com/css?family=Merriweather:400,400i,700|Source+Sans+Pro:300,400,600,700">

Fatal error after creating a new project

I ran through flynt create, setup my virtual host, then went to the site.

There's a call to get_fields in the LayoutMultiplePosts component, but I don't have ACF enabled.

Notice: Array to string conversion in /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Features/Acf/Loader.php on line 106

Notice: Array to string conversion in /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Features/Acf/Loader.php on line 106

Notice: Array to string conversion in /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Features/Acf/Loader.php on line 106

Notice: Array to string conversion in /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Features/Acf/Loader.php on line 106

Fatal error: Uncaught Error: Call to undefined function Flynt\Components\LayoutMultiplePosts\get_fields() in /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Components/LayoutMultiplePosts/functions.php:17 Stack trace: #0 [internal function]: Flynt\Defaults::Flynt\Components\LayoutMultiplePosts\{closure}(Object(Timber\Post)) #1 /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Components/LayoutMultiplePosts/functions.php(20): array_map(Object(Closure), Array) #2 /Users/michael/www/testing-yeah/web/wp/wp-includes/class-wp-hook.php(300): Flynt\Defaults::Flynt\Components\LayoutMultiplePosts\{closure}(Array) #3 /Users/michael/www/testing-yeah/web/wp/wp-includes/plugin.php(203): WP_Hook->apply_filters(Array, Array) #4 /Users/michael/www/testing-yeah/web/app/mu-plugins/flynt-core/lib/Flynt/BuildConstructionPlan.php(106): apply_filters('Flynt/addCompon...', Array, Array, Array) #5 /Users/michael/www/testing-yeah/web/app/mu-plugins/flynt-core/lib/Flynt/BuildConstructionPlan.php(28): Flynt\BuildConst in /Users/michael/www/testing-yeah/web/app/themes/testing-yeah/dist/Components/LayoutMultiplePosts/functions.php on line 17

Remove Wordpress Image Sizes

Since we are using Timber and Twig to resize our images, we don't need the data and file bloat anymore that comes with Wordpress by default. The only "benefit" I can think of are ACF preview images, but should that even be considered?

I would create a feature that simply removes all image sizes (except maybe thumbnail?).

BaseComponent/MediaTextBlock [Refactoring]

  • Get rid of the default poster image and make the video image required
  • Refactor the readme file
  • check the master and the MediaTextBlock branch for refactoring
  • check the styling and refactor it (also poster image)

Move getting the Post and its fields from the template component to the MainLayout

It is much more useful to get the post and its fields in static components as well. Without this change, it is necessary to get the post / the field(s) once more in those static components.

I tried changing this in a project already and havent encountered any problems with it yet.

@domtra I remember you having some reason not to do this, but can't quite recall. What do you think?

EDIT: Depending on the decision in #69 this might not be relevant anymore.

Add related static fields in page to $data of the component

This is necessary when adding fields that are a page-wide setting for a component and not a part of the component (instance's) own fields.

Example: I have a PageSettings field group that has a feature image field for the HeaderImage Component:

{
  "name": "pageSettings",
  "title": "Page Settings",
  "menu_order": 0,
  "style": "seamless",
  "fields": [
    "Flynt/Components/HeaderImage/Fields/PageSettings"
  ],
  "location": [
    [
      {
        "param": "post_type",
        "operator": "==",
        "value": "page"
      }
    ]
  ]
}

And in my fields.json of the component:

{
  "pageSettings": [
    {
      "name": "headerFeatureImage",
      "label": "Header Feature Image (Optional)",
      "type": "image",
      "instructions": "Recommended Size: Min-Width 1440px; Min-Height: 368px; Image-Format: JPG",
      "min_width": 1440,
      "min_height": 368,
      "mime_types": "jpg,jpeg"
    }
  ]
}

The value of that field I can only get the following way currently:

add_filter('Flynt/addComponentData?name=HeaderImage', function ($data) {
  global $post;
  $data['headerFeatureImage'] = get_field('headerFeatureImage', $post->ID);

  return $data;
}

It would be nice if that value was simply added to the related component instead like with everything else.

Refactor GoogleAnalytics Feature

  • Currently doesn't work due to a bug with globalOptions in the ACF Feature.
  • The JS code should be extracted into a twig file and not be inline.
  • reformat some code (don't use if :, elseif :, endif :)

BaseComponent/MediaSlider [Refactoring]

  • Refactor the stylesheet: remove all configuration
  • Think and refactor if needed the Slick slider stylesheet
  • Refactor the Slick slider configuration js
  • Check markup and refactor if needed
  • Then also refactor readme.md file
  • fields: Check required fields : make the image required, get rid of the default image

[docs] - page links to missing page

We should collect all missing page links in this issue so we can handle them all together.

The first missing link is here:
getting-started/dynamic-component.html

image

BaseComponent/ImageHero [Refactoring]

  • Make the image required
  • Refactor the whole approach of the styling without using the global variables
  • Check the markup and clean it (check differences between the master and the ImageHeroClassStates branch
  • Refactor the readme file (still jade references etc)

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.