Coder Social home page Coder Social logo

nachtfunke / basic-pattern-repository Goto Github PK

View Code? Open in Web Editor NEW
259.0 5.0 1.0 753 KB

Simple patterns for <use>. Just SVG - for your delight!

Home Page: https://patterns.helloyes.dev

License: GNU General Public License v3.0

JavaScript 6.56% Shell 0.19% Nunjucks 29.03% SCSS 27.28% HTML 36.93%
eleventy svg svg-patterns vanilla-javascript

basic-pattern-repository's Introduction

Basic Pattern Repository

Netlify Status License: GPL v3

Welcome to my weird little side project. Yes, I have finally done it. I have made something on the side. But considering the fact that I am currently looking for a new job... WELL.

what is this

This thing is a collection of hand-made <patterns> intended to be used in inline svg. It's a result of a bit of a design journey, in where I used a set of super simple shape-illustrations on my website but I wanted them to be able to reflect whatever color users were able to override in the settings. I used patterns from a figma library I created, based on someones pictures that they published before figma community libraries where a thing. But I had troubles exporting them as SVG, so I had to recreate them and had a horrible time doing it. So I thought it might be a good reason to learn some hand-coding SVG.

Copy & Paste <pattern>'s

This is what came out of this. A collection of simple, tileable SVG <patterns>. Their main use is to be pasted into a <defs> Element to then be used as a fill property or stroke property. But, because its super simple in eleventy, there is also output as

Download SVG File(s)

You can also download each pattern as a standalone .svg file. This makes it easily usable as a background-image in CSS. We can't reference patterns as background images from inline SVG in CSS (yet). But there is also the option to use a sprite, that utlizes the <view> element to allow accessing a single pattern with a URL Fragment Identifier.

Get from API

I made a simple complementary JSON output, that maybe someone can use? I wasn't sure but because I was using eleventy, doing that is super trivial. So why not.

Patterns

To get a JSON response containing all available data:

https://patterns.helloyes.dev/api/patterns.json

This contains all patterns as entries.

Single Pattern

To get a JSON response for a specific pattern:

https://patterns.helloyes.dev/api/pattern/{{ number }}.json

This doesn't contain any SVG Code. But it contains a field with a link to where the SVG code for a given pattern lives in svg. This points not to the <pattern> alone but instead to a fully working svg file that uses said pattern. Pls let me know if you would like this to work differently!

How to Contribute

If you want to contribute to this, you are free to do so. Mainly I believe this would mean adding patterns. If you are already familiar with eleventy and how it works, then all you have to do is

  1. add a new entry in src/content/patterns, check previous file names for the current naming convention.
  2. You can add yourself as the source, but be aware that this will require you to provide an URL. Can be a codepen, a Tweet but preferrably a link from your own site, as this link will be set as a canonical URL in the single view.
  3. Provide the SVG Code. Make sure to set patternUnits="userSpaceOnUse" and stroke="currentcolor" style="stroke: var(--pattern-channel-1, currentcolor)" (or fill, respectively).
  4. And that's it.

If you need to get this project running locally

It's rather straightfoward. It uses no external build tools but the ones provided by eleventy itself. You can utilize netlify dev to run it or just use npm run start in your terminal, which will start eleventy's serve mode and a watch task for sass too.

Should you need to build the site with npm run build, you are gonna need to install pupeteer on your system. I am using Stephanie Eckles eleventy-plugin-social-images to generate social images and if this is not installed, the build will fail.

You can also build the site without also building the social images: run-s -l clean eleventy:build sass:build.

basic-pattern-repository's People

Contributors

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

Forkers

alolalo

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.