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

@equinor/mad-components

v0.14.8

Published

A React Native component library implementing the Equinor Design System.

Downloads

1,161

Readme

MAD Components

This is a library of EDS components for React Native. Using this library should feel similar as for EDS for React.

🧑‍🏫 How to use

Installation

npm

npm install @equinor/mad-components

yarn

yarn add @equinor/mad-components

NOTE:

The component library requires the following libraries to properly function:

Please make sure to follow these installation instructions before using this package.

Getting started

Before using the components in your app, make sure to load the fonts and assets required by the library somewhere in your root component. It is also recommended that you wrap your app in the EDSProvider. This will give you access to dynamically switching between tablet and phone mode as well as dark and light mode support:

export default function App() {
    const [hasLoadedEds, edsLoadError] = useEDS();
    if (!hasLoadedEds) {
        return null;
    } else {
        return (
            <SafeAreaProvider>
                <EDSProvider colorScheme="light" density="phone">
                    <Navigation colorScheme="light" />
                    <StatusBar />
                </EDSProvider>
            </SafeAreaProvider>
        );
    }
}

🖼️ Theming

Creating stylesheets that use EDS values is made to be easy and performant. Start by creating a EDSStyleSheet, almost just like for a normal React Native StyleSheet:

const themeStyles = EDSStyleSheet.create(theme => ({
    container: {
        backgroundColor: theme.colors.container.background,
        borderRadius: theme.geometry.border.containerBorderRadius,
    },
}));

Notice that we pass theme into our style sheet. This is a resolved token based on the current configuration of the app. This means that the value for theme.colors.container can change between light/dark mode without you having to worry about anything 😎

We resolve our stylesheet in our components using the provided useStyles hook:

const MyComponent = () => {
    const styles = useStyles(themeStyles);
    return <View style={styles.container} />;
};

Ideally, all styling, be it conditional or not should happen outside of our components to reduce clutter. The EDSStyleSheet.create callback method accepts a second optional argument which allows you to pass any additional props into the style sheet:

// Notice that we type our second argument!
const themeStylesWithProps = EDSStyleSheet.create((theme, props: { color?: string }) => {
    const backgroundColor = color ?? theme.colors.container.background;

    return {
        container: {
            backgroundColor,
        },
    };
});

We are then required by our useStyle hook to pass these props in with the EDSStyleSheet:

const MyOtherComponent = () => {
    // Normally you'd pass some of your component props into this hook.
    const styles = useStyles(themeStylesWithProps, { color: "red" });
    return <View style={styles.container} />;
};