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

react-native-smart-styles

v0.2.0

Published

Smart stylesheets for React Native applications to design once and easy

Downloads

449

Readme

Buy Me A Beer   NPM Version   NPM Downloads   NPM License   Mimified Size  


Table of Contents

  1. Introduction
  2. Installation
  3. Configuration
  4. API Reference
  5. Migrating to v0.0.4
  6. Contributing

Introduction

React Native Smart Styles is designed to streamline the creation of style sheets in React Native projects by automatically adjusting styles to accommodate different screen sizes. This package handles all the heavy lifting, allowing developers to write styles quickly and easily without the need to manually account for device variability.

Installation

To install the package, run the following command in your terminal:

 npm install react-native-smart-styles
 # or
 yarn add react-native-smart-styles

 # after install
 pod install

Configuration

Using smart-styles.config.json

You can customize font names and colors by creating a smart-styles.config.json file in the root of your project. This JSON file allows you to specify your preferences which will be automatically applied during the package installation. Here’s an example of what the file might look like:

{
  "fonts": {
    "primary": "Arial",
    "secondary": "Roboto"
  },
  "colors": {
    "primary": "#333",
    "accent": "#007bff"
  },
  "baseWidth": 375,
  "baseHeight": 812
}

Updating Configuration with CLI

If you need to update your configuration after installation or if the smart-styles.config.json file does not exist, you can use the provided CLI tool. Simply run the following command:

smart-styles update

This command updates the configuration based on the settings specified in smart-styles.config.json.

Note: After updating the config file you might have to re-run the app

API Reference

Migrating to v0.0.4

Note: This is not the only migration process but this is the main one, for more information please refer to the docs

If you previously used useTheme to obtain themed styles, you will need to replace it with useThemeStyles in your code. Here is an example of how to update your code:

Before (v0.0.3)

import { useTheme } from 'react-native-smart-styles';

const MyComponent = () => {
  const styles = useTheme(unformattedStyles); // Returns styles object
  return <View style={styles.container}></View>;
};

After (v0.0.4)

import { useThemeStyles } from 'react-native-smart-styles';

const MyComponent = () => {
  const styles = useThemeStyles(unformattedStyles); // New hook for obtaining themed styles
  return <View style={styles.container}></View>;
};

// If you need to access the theme directly:
import { useTheme } from 'react-native-smart-styles';

const MyOtherComponent = () => {
  const theme = useTheme(); // Returns 'dark' or 'light'
  return <Text>{theme === 'dark' ? 'Dark Mode' : 'Light Mode'}</Text>;
};

Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!