springload/pattern-library

Name: pattern-library

Owner: Springload

Description: WIP: Pattern library in django.

Created: 2016-03-23 05:01:41.0

Updated: 2017-07-03 00:04:34.0

Pushed: 2016-04-08 04:04:43.0

Homepage: null

Size: 123

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Pattern Library

Screenshot

This is some very initial thinking about how a pattern library could work.

The pattern library has two simple goals:

What lives in the pattern library?
Naming conventions.

Installation
  1. Check out the project.
  2. Run pip install -r requirements.txt in the project root.
Starting the server

./manage.py runserver

View it on

http://localhost:8000

Creating new components

Use ./manage.py createcomponent my_app my_component to scafold the basic structure under my_app/components/


Installing into an existing Django Project

In PROJECT/settings.py:

Syntax

You load some data and pass it to a component.

This could be stored in a Python package:

omponent "button" data='example.conf.DEFAULT_BUTTON' %}

Or, set dynamically in the template:

ptions button_data %}

"class": [
  "btn",
  "btn-primary",
  "btn-options"
],
"attrs": {
    "data-button": "some-value"
},
"label": "{{ 'I changed the label' }}"

ndoptions %}
omponent "button" data=button_data %}

Or both:

oad_data "example.data.BUTTON_DATA" as common_data %}
ptions common_data button_data %}

"label": "{{ 'I changed the label' }}"

ndoptions %}
omponent "button" data=button_data  %}
Custom components
Setup your app
  1. Create a new application ./manage.py startapp my_app
  2. Update PROJECT/settings.py:
  3. Add my_app to INSTALLED_APP before patterns
  4. Add os.path.join(BASE_DIR, 'my__app', 'components') to TEMPLATES['DIRS'] before os.path.join(BASE_DIR, 'patterns', 'components')

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.