npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

Synergy

v3.10.3

Published

A front-end framework for building modular, configurable and scalable UI components

Downloads

42

Readme

GitHub license GitHub license npm version npm version

A front-end framework for creating modular, configurable and scalable UI components

Useful Wiki Pages

View SassDoc Documentation | View JSDoc Documentation

Overview

Synergy provides powerful APIs to help you create configurable modules in Sass, JavaScript and/or React:

Synergy is ideal for creating your presentational React components when using the Container Component Pattern (learn more)

Synergy also povides tools allowing you to combine the above aspects together to create a Synergy Module. Each aspect can work independently and exists as a separate file with a specific role:

These are the core concepts of a UI module.

|-- modules
|   |-- accordion
|   |   |-- accordion.js
|   |   |-- accordion.json
|   |   |-- accordion.jsx
|   |   |-- accordion.scss

Synergy modules can be configured and scaled without having to touch the module's source code

A Synergy module is composed of Components. Both Modules and Components can have Modifiers.

Using Synergy, you can create themes and control your entire project's UI from a single JSON file by passing custom options and parameters to your modules.

Learn more about creating themes

Example

Using Synergy to create a basic accordion module which will be configured by accordion.json - Learn more about this example

Structure

|-- UI
|   |-- modules
|   |   |-- accordion
|   |   |   |-- accordion.js
|   |   |   |-- accordion.json
|   |   |   |-- accordion.jsx
|   |   |   |-- accordion.scss
|   |-- app.scss
|   |-- app.{js|jsx}

Fundamental Styles (accordion.scss)

Learn more about module styles

@import '../../node_modules/Synergy/dist/synergy';

@import 'accordion.json';

@mixin accordion($custom: ()) {

    $config: config($accordion, $custom);

    @include module {
        @include component('panel') {
            &:not(:last-child) {
                margin-bottom: this('panel', 'vertical-rhythm');
            }

            @include modifier('active') {
                @include component('toggle') {
                    transform: rotate(90deg);
                }

                @include component('content') {
                    display: block;
                }
            }
        }

        @include component('title', (
            'display': block,
            'cursor': pointer
        ));

        @include component('toggle', (
            'float': right
        ));

        @include component('content', (
            'display': none
        ));
    }
}

Accordion Interface - JSX (accordion.jsx)

Learn more about module interfaces

import React from 'react';
import { Module, Component } from 'Synergy';

import config from './accordion.json';

export default Accordion = ({ panels, ...props }) => (
    <Module name={config.name} {...props}>
        {panels.map(({title, content}, index) => (
            <Component name="panel" key={index}>
                <Component name="title" onClick={toggle}>
                    <Component name='toggle' /> {title}
                </Component>
                <Component name="content">{content}</Component>
            </Component>
        ))}
    </Module>
);

function toggle(event) {
    const panel = event.target.closest('[data-component="panel"]');

    panel.modifier('active', 'toggle');
}

You could move the toggle interaction (and any other module interactions) into a separate accordion.js file

Accordion Interface - Plain JavaScript (accordion.js)

import { Synergy } from 'Synergy';

import config from './accordion.json';

export default function accordion() {
    Synergy(config.name, accordion => {
        accordion.component('panel', panel => {
            panel.component('title', title => {
                title.addEventListener('click', toggle.bind(panel), false);
            });
        });
    });
}

function toggle() {
    this.modifier('active', 'toggle');
}

Accordion Configuration (accordion.json)

Learn more about module configuration

This is where cosmetic (and hence configurable) styles are applied to the module and its components

{
    "accordion": {
        "name": "accordion",
        "panel": {
            "vertical-rhythm": 0
        },
        "title": {
            "background": "transparent",
            "color": "#444444",
            "border": "1px solid rgba(black, 0.15)",
            "border-radius": 0,
            "padding": "1em",
            "transition": "0.4s",
            "hover": {
                "background": "#2E3882",
                "color": "white",
                "component(toggle)": {
                    "color": "white"
                }
            },
            "active": {
                "background": "#2E3882",
                "color": "white",
                "border-color": "transparent",
                "border-radius": 0,
                "component(toggle)": {
                    "color": "white"
                }
            }
        },
        "content": {
            "background": "white",
            "color": "#444444",
            "border": "1px solid rgba(black, 0.15)",
            "border-radius": 0,
            "padding": "1.5em"
        },
        "toggle": {
            "color": "rgba(black, 0.4)",
            "transition": "0.4s"
        }
    }
}

Loading Styles (app.scss)

@import '/modules/accordion/accordion';

@include accordion();
With Custom Options
@import '/modules/accordion/accordion';

@include accordion((
    'panel': (
        'vertical-rhythm': 2em
    ),
    'title': (
        'background': #06d2ff,
        'color': white
    )
));

Render Using React (app.jsx)

<div id="demo"></div>
import React from 'react';
import ReactDOM from 'react-dom';

import Accordion from './modules/accordion/accordion.jsx';

ReactDOM.render(
    <Accordion panels={[
        {title: 'foo', content: 'bar'},
        {title: 'fizz', content: 'buzz'},
    ]} />, 

    document.getElementById('demo')
);

Or Initialise Using Plain HTML/JavaScript (app.js)

<div class="accordion">
    <div class="accordion_panel">
        <div class="accordion_title">
            <div class="accordion_toggle"></div> foo
        </div>
        <div class="accordion_content">bar</div>
    </div>
    <div class="accordion_panel">
        <div class="accordion_title">
            <div class="accordion_toggle"></div> fizz
        </div>
        <div class="accordion_content">buzz</div>
    </div>
</div>
import accordion from './modules/accordion/accordion.js';

accordion();

Creating a Theme

Using Synergy, you can create themes and control your entire project's UI from a single JSON file by passing custom options and parameters to your modules.

Learn more about creating themes

Changelog

Version 3.10.3

Released: 1st July 2018

Release Notes
  • Updating to node-sass 4.9.0
  • Fixing regression bugs as a result of node-sass update

Version 3.10.2

Released: 25th June 2018

Release Notes
  • Bug fixes

Version 3.10.1

Released: 25th June 2018

Release Notes
  • Bug fixes

Version 3.10.0

Released: 20th June 2018

Release Notes
  • Added callback functions to component and modifier DOM methods
  • Allowing <Component>'s to accept event handlers as props
  • Allow passing of custom HTML tag to <Module>
  • Set module modifiers by passing as empty prop
  • Adding <Wrapper> and <Group> components
  • Specify list of CSS classes to add via empty prop
  • Allow passing of CSS through Sass map istead of through @content
  • Adding sub-component Sass mixin
  • Adding pseudo-state Sass mixin
  • Adding Synergize class (extends React.Component)
  • Dynamically fetch <Component> onClick event from window.Synergy object
  • Option to render content by passing as content prop
  • Set <Module> as another module by passing module name as prop
  • Dynamically set tag prop on module if name prop is valid HTML tag
  • Get HTML attributes from props
  • Components now render with a data-component attribute
  • Allow passing of data-attributes to module
  • Append content before/after module through before and after props
  • Removing Bower
  • General refactoring, syntax improvements and bug fixes