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

solids

v0.2.8

Published

CSS-only Material Design Primitives

Downloads

35

Readme

solids

CSS-only Material Design Primitives

npm license installs mind BLOWN

.

logo

Install

npm install --save solids

Use

To use solids styles in your app, I recommend webpack with the sass-loader. Make sure to import the required solids sass files in your code. Always import the base styles from solids/solids and any additional styles for the components you are using.

Import

You can import the solids styles from some sass file in your project:

index.scss

@import "solids/solids";
@import 'solids/appbar';

/* your own styles */

Alternatively, you can import the solids styles from some JS file in your project:

index.js

import "solids/solids";
import 'solids/appbar';

/* your javascript code */

Render markup

Allmost all the markup for solids is static. Meaning you render it once and from there on it stays the same. This is unline in MDC-web, where all sorts of behaviors are triggered by toggling CSS class names on the component. In solids, we only use CSS class names to configure the component, but not to manage its state.

Make sure to render your components within an element with class="solids":

<!DOCTYPE html>
<html>
  <head>
    <title>Example</title>
  </head>
  <body>
    <!-- establish a `solids` context -->
    <div class="solids">
      <!-- render `solids` components -->
      <header class="appbar">
        <!-- ... -->
      </header>

      <!-- ... -->
    </div>
  </body>
</html>

To keep the markup simple and CSS class names short, all solids CSS classes are combined with the .solids class so they are scoped to only work within the class="solids" context element. For example, the appbar styles selectors look like:

.solids .appbar {
  /* only targets elements with class="appbar" within elements with class="solids"
}

Using with Preact

If you are using Preact, check out preact-solids which can render the markup for you.

Using with CSS Modules

If you are using the CSS Modules loader, you need to use the correct class names as transformed by the CSS Modules loader when rendering the HTML. To facilitate building components that support both forms, with and without CSS modules, each solids component publishes a JS file in addition to the SASS files which contains an object in the same format as produced by CSS Modules with the default class names used in the component. For example, for the AppBar component, we have solids/appbar/classes.js:

solids/appbar/classes.js

module.exports = {
	appbar: 'appbar',
	fixed: 'fixed',
	dense: 'dense',
	prominent: 'prominent',
	short: 'short',
	collapsed: 'collapsed',
	has_action: 'has_action',
	shrink: 'shrink',
	floating: 'floating',
	start: 'start',
	end: 'end',
	reserve: 'reserve',
	title: 'title',
	icon: 'icon',
	action: 'action',
	tactile: 'tactile',
};

You can use this object as a public interface for rendering your markup:

import classes from 'solids/appbar/classes'

function render() {
  return `
    <header class="${classes.appbar}">
      <!-- ... -->
    </header>
  `
}

When using CSS Modules, you would import the classes directly from the styles:

import classes from 'solids/appbar'

function render() {
  return `
    <header class="${classes.appbar}">
      <!-- ... -->
    </header>
  `
}

You can even combine this with preact-context or something similar to create components that support both CSS Modules or unscoped class names or even a mix at the same time! Have a look at how preact-solids implements this with its preact-solids/theme component.

Issues

Add an issue in the issue tracker to let me know of any problems you find, or questions you may have.

Credits

Credits go to:

Copyright

© 2019 by Stijn de Witt. Some rights reserved.

License

Licensed under the MIT Open Source license.