GithubHelp home page GithubHelp logo

singularity's Introduction

🚨 Singularity is no longer maintained. CSS Grid is nice, you should use that instead.

Singularity.gs Gem Version Build Status

Grids Without Limits

Singularity is a next generation grid framework built from the ground up to be responsive. What makes Singularity different? Well, a lot of things. Singularity is based on internal ratios instead of context based which allows for better gutter consistency across breakpoints. Ratio based math also allows for non-uniform grids in any unit you want to use.

CSS Grids and Singularity

Layout on the web has changed significantly since Scott's first push back on March 7, 2012. First came Flexbox, then CSS Grid. CSS Grid provides layout functionality that covers all of Singularity's usecases and then quite a few more that we were never really able to support.

With the release of Singularity 1.8, two new mixins, grid-container and css-grid-span. These two mixins are not included by default when importing Singularity, and will need to be included separately by doing @import 'singularity/css-grid' after following the install instructions.

These Mixins Are Not Meant To Be Used As A Replacement For CSS Grid

The purpose of these mixins is to provide users with a way to transition off of Singularity and start using CSS Grid directly. CSS Grid is powerful, and doesn't need a framework like Singularity, and we encourage our users to start using it directly whenever possible instead of Singularity. This also means there will be no further updates to Singularity for the forseeable future. We love all of our users, and thank you for your support over the past 5 years. Singularity will continue to work as normal, but further development will stop.

Documentation for the CSS Grid mixins can be found below;

Getting Help with Singularity

  • For help with Singularity, please ask a question on Stack Overflow tagged with singularitygs.
  • To file an issue with Singularity, be it a feature request or a bug report, please use our Issue Queue.

Singularity Quickstart

Full documentation is available on the Singularity Wiki

If you are upgrading to Singularity 1.2.0 or greater, please read the Changelog for important changes made to Singularity!

Installation

  • Singularity should be installed and compiled through Bundler if compiling with Ruby
  • Alternatively, Singularity can be installed with Bower (bower install singularity --save)
  • It can even be installed as an Eyeglass module! (npm install singularitygs --save-dev)
  • Singularity requires a Sass compiler with full feature parity with the Ruby Sass 3.4.23 implementation in order to work

Setting Up a Basic Grid

Grids are made of 3 parts, the Grid definition defining columns, Gutter definition defining spacing between columns, Gutter Style defining how gutters are positioned relative to a column. Singularity supports Symmetric and Asymmetric grids, as well as fluid and fixed gutters. Setting grids up this way puts them into Singularity's Global Grid Context.

// Symmetric grid with fluid gutters, 1/2 gutter on each side of a column
@include add-grid(12);
@include add-gutter(1/3);
@include add-gutter-style('split');
// Asymmetric grid with fixed gutters, 1 full gutter after each column
@include add-grid(1 3 5);
@include add-gutter(1em);

You can visualize your grid with a CSS Gradient. To do so, turn on debug mode and include the background-grid mixin. Be warned, CSS Gradients aren't 100% reliable visualizations, if there's a discrepancy between the visualization and the actual items on the grid, it's most likely the visualization that's wrong.

// Be sure to enable debug mode for your grid visualization so show up:
@include sgs-change('debug', true);

.container {
  @include background-grid($color: blue);
}

Spanning Your Grid

Singularity doesn't provide grid classes, instead it uses mixins to attach an item to your grid. The mixin takes your grid definitions and an output style and writes the CSS for the given combination. The main mixin for this is the grid-span mixin which will work with any output style. Most output styles provide output-specific spans to make working with that specific output style easier.

The grid-span mixin takes two required arguments, how many columns you would like to span, and from what column you would like to start from. The column you would like to start from is the first column spanned.

@include add-grid(4);

.foo {
  // Spanning the last 2 columns
  @include grid-span(2, 3);
}

.bar {
  // Spanning the 2nd column
  @include grid-span(1, 2);
}

Responsive Grids

Singularity provides a couple of different ways to have grid-span use a different set of grid definitions at different breakpoints. The first is Singularity's Responsive Grid Context, which relies upon Breakpoint (a super powerful and flexible media query system, we recommend using it). This will allow you to use Breakpoint media queries as normal and when grid-span is called, it will know what set of grid definitions to use (although it won't automatically change existing grid-span calls to put them on a new grid, that's up to you). It does this by allowing for multiple grid definitions in the Global Grid Context.

To use, simply call add-grid multiple times, each time telling it when you would like to change. Be Aware this will only work with min-width media queries! Sass and Singularity cannot know runtime conditions and provide wiggle room between media queries with anything other than simple min-width queries. While a full Breakpoint style media query can be used in these definitions, Singularity will only look for the min-width value.

Responsive grid contexts do not output anything by themsleves. Singularity's Responsive Grids feature allows you to change the context of a called grid-span. In order for you to see the context change, you still need to call grid-span to apply your grid.

// Singularity 1.2 Syntax
@include add-grid(3);
@include add-grid(6 at 500px);
@include add-grid(12 at 700px);
@include add-grid(2 8 2 at 900px);
@include add-grid(1 3 5 7 9 at 1100px);

@include add-gutter(1/3);
@include add-gutter(.25 at 900px);

The second way to provide responsive grids is with either of the use of the Context Override mixins. Singularity provides two, layout which will override context Global Grid Context for any content nested underneath it, and layout-at, which will do the same but allows you to define and use a media query at the same time. layout-at will accept any Breakpoint media query definition. Both of these options provide more fine-grain control over your Global Grid Context overrides as compared to the Responsive Grid Context, if you need that.

@include add-grid(12);
@include add-gutter(1/3);

.foo {
  @include layout(1 3 5, .5) {
    // Everything in here will use a `1 3 5` grid with `.5` gutter.
    // Arguments (in order): $grid, $gutter, $output-style, $gutter-style
  }

  @include layout((
    'grid': 1 3 5,
    'gutter': .5
  )) {
    // Everything in here will use a `1 3 5` grid with `.5` gutter

    // Also available: 'gutter style' and 'output'
  }


  @include layout-at(2 4 6, 500px) {
    // Everything in here will be wrapped in a `min-width: 500px` media query
    //   and use a `2 4 6` grid with the Global Grid Context's `1/3` gutter
  }

  @include layout-at((
    'grid': 1 3 5,
    'gutter': .5
  ), 700px) {
    // Everything in here will be wrapped in a `min-width: 700px` media query
    //   and use a `1 3 5` grid with `.5` gutter

    // Also available: 'gutter style' and 'output'
  }
}

CSS Grid

Singularity 1.8 introduces the following optional mixins to use current grid definitions to provide CSS Grid layouts for browsers that support it, and fall back to Singularity layouts for browsers that do not.

@import "breakpoint";
@import "singularitygs";
@import "singularitygs/css-grids"; // Optional module, needs to be imported separately

.container {
  @include grid-container; // Will write  grid-template-columns, grid-gap, and padding definitions (wrapped in @supports) based on grid definitions previously defined
}

.item {
  @include css-grid-span(3) // Spans with no location only work for symmetric grids. Will write a float-based span as a fallback to grid-columns
}

.item-2 {
  @include css-grid-span(2, 1) // Spans with a location will work with asymmetric grids. Will write either an isolation or calc based span as a fallback to grid-columns (depending on the defined grid)
}

Contributing to Singularity

We love contributors! Yes we do! If you would like to contribute to Singularity, please follow the Contributing Guidelines

Singularity Plugins

Having been designed to be extensible, the ability to create plugins for Singularity is great and we expect to see great things. From new Output Span syntaxes to new Output Styles to new Grid Generators, we are excited to see what the community will come up with. Below are a list of Singularity Plugins available. If you would like to add your Plugin to the list, please issue a Pull Request to add it to the list!

License

Dual license MIT/GPL-3.0

singularity's People

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

singularity's Issues

Rounding errors

There seem to be rounding errors.

I have a 5 column grid with 188px each column and 10px gutter width, which sums up to 188 * 5 = 940px + 40px gutters = 980px.
Singularity calculates the gutters like so: 10px, 11px, 11px, 13px and the columns are all only 187px wide.

here is the scss file

@import "compass/reset";
@import "compass";
@import "singularitygs";


$columns:   188px 188px 188px 188px 188px;
$gutter:    10px;
$color:     #888;
$padding:   20px;

@include grid-objects(a, $columns, $gutter, $padding, $selector:".");

.wrapper
{
    max-width:980px;
    height:100%;
    margin:0 auto;
    background:green;
}

.foo 
{
    background:$color;
    padding-top:$padding;
    padding-bottom:$padding;
}

and the html code

<html>
    <head>
        <title>Grid test page</title>
        <link href="stylesheets/screen.css" rel="stylesheet">
    </head>
    <body>
        <section class="wrapper">
            <section class="foo a0-1">
                bla
            </section>
            <section class="foo a1-2">
                bla
            </section>
            <section class="foo a2-3">
                bla
            </section>
            <section class="foo a3-4">
                bla
            </section>
            <section class="foo a4-5">
                bla
            </section>
        </section>
    </body>
</html>

Push/Pull

With the traditional Float style output, we now need to include a way to pull/push columns.

test-grid error calling grid-span/IE fixes

In trying to test for IE I found that the grid-span call inside of test-grid was failing saying there was no margin or padding value. Also using transparent backgrounds for the test-grid does not work for most IE. Need to update that to a solid color fallback.

Optimize CSS output

Optimize styles written by mixins. Consolidate general styles to make file size tiny.

Custom $gutter not working in +grid-span

This was an issue that @canarymason brought up to me on Twitter that I believe I've tracked down and solved. column-span currently doesn't take $gutter as an input variable, and as such, grid-span function doesn't pass the one it takes in, and as such custom gutters don't currently work. I'm going to do some more Q/A on this, but I do believe this is solved.

Column alignment issue

I'm experiencing a weird column alignment issue on a very simple 12 column grid.

.grid {
@include grid-objects(a, 12, 2%, $selector: ".");
}

a3-6 and a6-9 are aligned further to the right than they should be. they go off the proposed grid, because the margin-left calculation appears to be off.

Grid output style API

Started this in the branch for issue #32 and what we need is an API to plug in different styles of grids. CSS is evolving with better tools to create grids. Making a way to expand and evolve output with those features is just as important as the API for creating different kinds of grids.

Documentation

Write docs showing how to use the grid and everything included in it.

Test in IE

Lots of testing needed, especially in IE. Probably not too many issues but should test.

inline-table

Check out inline-table on columns. They might be more flexible and widths calculated with fewer rounding errors. Also no need for floats. Another advantage is that all elements in a row will be equal height, no need to clear anything in new columns. Trivial to center-align content by must using display: table-cell;.

Watch out for white space messing with layout as inline elements tend to have stray spaces.

Ratio spiral

Got this on paper in my notebook, for writing grids like this:
spiral

Rounding errors in gutter calculations.

NOTE: Slight rounding errors happen in gutter calculations causing a slight offset to the overall column width. Different than browser rounding errors which almost every grid system has, these only effect gutters and the larger the gutters, the higher the probability the errors will be noticeable.
— Scott

If I've got a setup as follows:

$columns: 8, 4, 3;

and I want something to span the whole width, I should be able to do something like this:

#foo {
  @include grid-span(3, 1)

which does give me it spanning the full 3 columns, but also adds in the $gutter to the side. I know this something that susy solves by having a full row be clear: both, but we either need to realize that should be full width and do it, or we need to explicitly define how to do a full width in the docs.

Container?

Unlike Susy, Singularity doesn't seem to have a container mixin (at least not one I could see). Interested in adding one in? It also may make doing things like having adjustable grid layouts at different breakpoints more feasible.

recursive contexts

I'm diving into this and gridset this week, and the feature both are lacking (or maybe I'm missing it) is what I'm calling recursive contexts. I've got a layout with a main content section, and a sidebar section. I want to subdivide the main section and align nested elements in there to an overall grid. This is done in even grids like susy by setting the 'context' of the nested elements. I think singularity needs that concept as well.

Here's an illustration for clarity.

Padding?

What is the purpose of specifying padding as part of the grid definition? Is was my assumption that that's what the gutters were for, and if additional padding was needed, a per-element padding would be added. Is it to help with calculations of widths? If so, thoughts on using border-box and not having this issue? Just a little confused as to the thinking here.

Update Website

The website is falling a bit out of date thanks to rapid development cycle we have and it needs to be updated.

page margins/wrapper

Most designs that I'm aware of don't but up right against the edges of the screen and instead have some sort of edge gutter, but singularity doesn't have this concept. Thoughts on adding it in?

Interprut fixed width context

Currently the functions treat all values as numbers. Pixels can be used for columns but they aren’t given special treatment.

Some features would be easier ability to implement photoshop pixel based designs and pixel based gutters would be added to the context instead of subtracted.

This also adds complexity to the code. This framework is designed for designing in the browser and I don’t see the value in adding support for this.

On the fence about this. If you want it, convince me.

Applying grid-span to multiple elements

Not a bug, just a question.
When you have something like, for instance:

How can you apply the grid-span at once for the three elements?
If I try @include grid-span(1); so that each article span one column i get the following error:

error main.scss (Line 140: Mixin grid-span is missing argument $location.)

I know what location is, but to explicitly apply it i would need to target each article individually which is not the goal here.

Just wanted to know if theres anyway to do this.

This is an exciting project and thank you for sharing it.

Update Documentation

While probably not a blocker for a 1.0 release, we seriously need to update the documentation for Singularity as it can do so frickin much right now that I don't even think I know all of the nooks and crannies of the system. At the least for the 1.0 release, we need to document Grid Output API and then work on a cleanup.

Gridset or grids

Any reason why $grids is not an appropriate variable? Short, simple, easily typed and simply the plural of $grid.

Also distancing Singularity from gridset might be a good idea. Not that we should go out of our way to do so but this is an easy area to avoid confusion.

Better Debug Guidelines

It seems as if the background-grid mixin isn't so smart, especially with non-uniform grids, and we should come up with a better mixin for this.

Identify “standard use case”

Singularity can do a lot, a hell of a lot witch introduces a learning curve to new users. We need to identify a standard use case to recommend and present as the way to do things. Of coarse other stuff should be documented but holding one thing up will give people one point of introduction.

Objects & mixin consistanty

objects and mixins use different language for how they fit on the grid. I have no idea what I was smoking when making that happen but extendable classes/% need to follow the same naming conventions as mixins.

Gridsets

A bit far off, but the ability to have different grids at different breakpoints would be awesome. We're going to need to think long and hard about the DX for this though.

better padding support

Add defaults for padding as well as support for padding in multi dimensional lists.

Equal padding on all columns:

$padding: 2%

Override padding on specific columns, This results in 2% padding on the second column:

$columns: 1, 1 2%, 1

Clean Up Singularity Example

I just ran into this issue when trying to create a test example. In our Examples config.rb file, it's loading Scott's local Singularity framework which no one else is going to have. I think we need to clean this up so that all of our examples are loading off of the stylesheets dir that we have in the branch, specifically:

@import '../../stylesheets/singularitygs';

This will make it so that any of us can run and build examples easily, off of our own boxes, and off of the current version of singularity in the branch we're on.

Rewrite in Ruby

I know this is a little premature, but I can see that the complexity of Singularity is starting to affect compile performance, so we should probably rewrite this in Ruby. This is most definitely blocked on sass/sass#310

Break list functions into accessible structure.

Compound grids and scales are just functions that plug into Singularity column lists. These should be broken out into a folder and documented.

This will allow functionality to grow as well as community developed extensions to Singularity and pull requests.

Import not found (singularitygs/helpers)

Im getting this error while compiling using the latest version (singularitygs 0.0.13):

error main.scss (Line 34 of _singularitygs.scss: File to import not found or unreadable: singularitygs/helpers.
Load paths:
/Users/luismartins/Sites/LAB/singularity/css-src
/Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets
/Library/Ruby/Gems/1.8/gems/compass-rgbapng-0.1.1/lib/stylesheets
/Library/Ruby/Gems/1.8/gems/bootstrap-sass-2.1.0.0/vendor/assets/stylesheets
/Library/Ruby/Gems/1.8/gems/sassy-math-1.2/stylesheets
/Library/Ruby/Gems/1.8/gems/modular-scale-1.0.2/stylesheets
/Library/Ruby/Gems/1.8/gems/breakpoint-1.3/stylesheets
/Library/Ruby/Gems/1.8/gems/singularitygs-0.0.13/stylesheets
Compass::SpriteImporter)
overwrite main.css

Ratio Grid Option

Like @canarymason had suggested, it would be awesome to have a simple way of creating ratio based grids, and I think Singularity is basically all set up to do this already, sans the actual math behind it (which I think I've figured out!)

Singularity currently supports floating point grid items as well as integers, and we'd need these in order to effectively create ratio grids. The syntax for ratio would be fairly simple as I see it:

ratio($ratio, $steps, $order: 'increase')

I'm currently experimenting to see if my math is right, and if it is, and you're interested in including it, happy to post it here/issue a pull request.

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.