Skip to main content

A module for Django that allows to build pattern libraries for your projects.

Project description

Django pattern library

A module for Django that helps you to build pattern libraries and follow the Atomic design methodology.

Objective

At the moment, the main focus is to allow developers and designers use exactly the same Django templates in a design pattern library and in production code.

There are a lot of alternative solutions for building pattern libraries already. Have a look at Pattern Lab and Astrum, for example. But at Torchbox we mainly use Python and Django and we find it hard to maintain layout on big projects in several places: in a project's pattern library and in actual production code. This is our attempt to solve this issue and reduce the amount of copy-pasted code.

Documentation

Documentation is located here.

How to install

  1. Add pattern_library into your INSTALLED_APPS:

    INSTALLED_APPS = [
        # ...
    
        'pattern_library',
    
        # ...
    ]
    
  2. Add pattern_library.loader_tags into the TEMPLATES setting. For example:

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
                'builtins': ['pattern_library.loader_tags'],
            },
        },
    ]
    

    Note that this module only supports the Django template backend out of the box.

  3. Set the PATTERN_LIBRARY_TEMPLATE_DIR setting to point to a template directory with your patterns:

    PATTERN_LIBRARY_TEMPLATE_DIR = os.path.join(BASE_DIR, 'project_styleguide', 'templates')
    

    Note that PATTERN_LIBRARY_TEMPLATE_DIR must be available for template loaders.

  4. Include pattern_library.urls into your urlpatterns. Here's an example urls.py:

    from django.apps import apps
    from django.conf.urls import url, include
    
    
    urlpatterns = [
        # ... Your URLs
    ]
    
    if apps.is_installed('pattern_library'):
        urlpatterns += [
            url(r'^pattern-library/', include('pattern_library.urls')),
        ]
    

Developer docs

Developer docs can be found here.

TODO

  • Add a note about production usage
  • Tests: Add tests. It's ok to not bother about tests during prototyping, but it will be extremely hard to maintain the project without tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-pattern-library-0.2.4.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

django_pattern_library-0.2.4-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file django-pattern-library-0.2.4.tar.gz.

File metadata

  • Download URL: django-pattern-library-0.2.4.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

File hashes

Hashes for django-pattern-library-0.2.4.tar.gz
Algorithm Hash digest
SHA256 0260b71ec1c12124f251dbeff055237b15e2a2e4e3a4b9f529dcb0b29ca030d4
MD5 a0b886658c689ee65c9ab30d97fe4b5d
BLAKE2b-256 7be3f0a98ae11d9a5675635c0a99a16d6b7edab6ed83fa0a0d4e25bbc566a8bb

See more details on using hashes here.

File details

Details for the file django_pattern_library-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: django_pattern_library-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

File hashes

Hashes for django_pattern_library-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 679c4137b863d4331911a33305a64d9efa3f56e4d9ce47a75555457a6facfe77
MD5 364f7b9507bed50dc16f44187e06bc7c
BLAKE2b-256 a0f31e7388bd9f6a978065804f357577d5c967a55b5294f4af1726f7b23d69e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page