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

@digitalroute/theme

v7.18.1

Published

DigitalRoute's theme.

Downloads

156

Readme

When to use the DR-Theme

  • When styling Ant Design components with styles that should apply to all components and not just specific ones.
  • When we start to repeat ourselfs in the styling of things e.g you specifing the same color for the 2:nd or 3:rd time.
  • When .....

How

Please note, this repository uses semantic release. Please read about it in the Conventional Commits page in Confluence.

  1. Run npm install to install dependencies
  2. Make your changes
  3. Make sure your changes are visible in the storybook (add a new story if necessary) and hasn't broken any of the existing ones: npm run storybook
  4. When you're satisfied with the result, stage your changes using git add and then commit using npm run commit. Add a nice descriptive comment about the changes.
  5. Push to your feature branch and create a PR.

Peer dependencies

Currently this module expects to find peer dependencies for react (^17.0.0) and antd (4.16.3) in your app.

Theme With react-jss

This is an implementation of theming react apps using react-jss. For smooth integration with antd, we have a custom webpack loader which parses the antd's LESS files and extracts all variables into the a theme which is provided in the app for usage when styling components. Hence, any changes of antd's components, and theme variables in general, is accomplished through setting the different LESS variables exposed by antd found in eg. ./src/theme.less.

One of the most important benefits of JSS is that it promotes components to be contained in a single file. This encourages and ensures pain-free future refactorings without also having to deal with external stylesheets. A list of benefits, as well as more useful information can be found att jss' website. The integration with antd also ensures that theming of the existing components is done seamlessly.

Whilst LESS is used in this module due to antd, there is no requirement for any consuming library to use LESS. Preferably, the functionality provided by JSS will be more than enough even for advanced stylerz.

The module exposes two utility functions for consumers to use, shortly explained below. Simple but complete examples can be found in ./stories/index.jsx. To show them live, run npm install && npm run storybook.

Whilst we haven't yet published this to an NPM registry, you can use the module by adding the following dependency:

"@digitalroute/theme": "git+ssh://[email protected]:7999/daz/dr-theme.git#<tag>"

withTheme(app: Component)

import { withTheme } from '@digitalroute/theme';

class App extends React.Component {
    render() {
        <SomeComponent />
        ...
    }
}
const ThemedApp = withTheme(App);

useStyles

useStyles are not exported by dr-theme, but to provide an example how to use it below, theme is injected by withTheme in the top of the application as shown above.

import { createUseStyles } from "react-jss";

// Styles only need to be a function when theme is used, object otherwise
const styles = (theme) => ({
    yolo: {
        display: 'flex',
        flexDirection: 'column',
        color: theme.primaryColor,
        ...
    },
    ...
});
const useStyles = createUseStyles(styles);

export const SomeComponent = () => {
    const classes = useStyles();

    return <div className={classes.yolo}/>
};

[LEGACY (Deprecated in react-jss v10)] Creates a higher-order-component (HOC) of your app that sets up and provides the theme. Typically, this is used near the root-component in an application and applied on a single component in the component-tree. Preferred to use only with class component, as useStyles hooks are replacing this.

withStyles(styles: func)

Creates a new function which in turn accepts a component to turn into a styled (HOC) version, through which the defined css-classes defined in styles are provided as a the "classes"-prop:

import { withStyles } from '@digitalroute/theme';
import { WithStylesProps } from '@digitalroute/theme';

const styles = (theme) => ({
    yolo: {
        display: 'flex',
        flexDirection: 'column',
        color: theme.primaryColor,
        ...
    },
    ...
});

interface Props extends WithStylesProps<typeof styles> {}

const SomeComponent = ({ classes }:Props) => (
    <div className={classes.yolo}>
    	...
    </div>
);

export default withStyles(styles)(SomeComponent);

TODOs

We'll eg. be looking into reducing the dist size.