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

rfq-widgets

v1.0.23

Published

- Getting Started - Launch Project - About Template - Project Structure - Atoms - Components - Styles Structure - Themes - Hooks - Libraries Added - References

Downloads

7

Readme

Index

  • Getting Started
    • Launch Project
  • About Template
  • Project Structure
    • Atoms
    • Components
    • Styles Structure
      • Themes
    • Hooks
  • Libraries Added
  • References

Getting Started

For install the dependencies, in the project directory, you can run:

npm install or yarn

Launch Project

In the project directory, you can run:

npm start or yarn start

Project Structure

The project structure is based in best practices for architecture, based in this template is for an simple widget o component, in case to need create an website whit pages and routing is recommend added the folders for an full website.

-- public/ -- src/ ---- Atoms/ ---- Components/ ---- Hooks/ ---- Styles/ --------- Atoms/ --------- Components/

Atoms

This are micro-components with the logics is simple and hinherited like a button, a list with a simple logic for reuse this

./src/Atoms/ |----Row/index.tsx |----Button/index.tsx |----Text/index.tsx |----Card/index.tsx

Example

For the example we will create an card using 2 components(you can use more) from style and inherited functions

import React from "react";
import { Text, Button } from "../../styles";

const Card = props => {
  return (
    <>
      <Text>{props.title}</Text>
      <Text>{props.subTitle}</Text>
      <Button title={props.title} onPress={() => props.action()} />
    </>
  );
};
export default Card;

Components

This is an specific component who use the atoms for develop an specific logic or function like view an list with data and buttons specific but using the atoms for made this. The components can use Hooks or Contexts for specifics calls or actions like transfer data or functionalities by the wrapper component like HOCs

./src/Components/ |---Carouse/index.tsx |---List/index.tsx |---Table/index.tsx

  • Components can be reuse in diferents modules on inside other components like a list inde a table component

Example

  • In this example card are imported inside a Slider conforming an Component reusable for and module or more modules.
import React from 'react';
import Card from '../../Atoms/Card';
...
const Catalog: React.FC<Props> = (props) => {
    return (
      <Slider>
         {props.cards.map((item) => {
            <Card image={item.img}>{props.title}</Card>
         })}
      </Slider>
    );
};

export default Catalog;

Styles Structure

  • for declare a new style componet this need import into ./src/styles/index.tsx and exported for use in the project

import Text from './Generics/Texts'; export {Text};

./src/styles/ |----index.tsx |----Generics/Texts.tsx |----Generics/Buttons.tsx

Example

create a new style component file with the next base:

./src/styles/Generic/Buttons.tsx

import React, {Button} from 'react';
import {Colors, Fonts} from './constants';
import styled from 'styled-components/native';
...
const TouchableOpacity = styled.TouchableOpacity`
flexDirection: row;
justify-content: center;
padding: 30px 15px;
width: 70%;
`;


interface PropsCircleButton {
primarycolor?: boolean;
secondarycolor?: boolean;
small?: boolean;
medium?: boolean;
nameicon?: string;
coloricon?: string;
sizeicon?: number;
children: string;
onPress?: () => void;
}

const TouchableCircle = styled.TouchableOpacity`
align-items: center;
justify-content: center;
${(props: any) =>
props.small &&
                  `
border-radius: 50px;
height: 20px;
width: 20px;
`}
${(props: any) =>
props.medium &&
`
border-radius: 50px;
height: 30px;
width: 30px;
`}
${(props: any) =>
props.primarycolor &&
`
background-color: #17a4cc;
`}
${(props: any) =>
props.secondarycolor &&
`
background-color: #fff;
`} `;

const CircleButton = (props: PropsCircleButton) => {
const {onPress, ...rest} = props;
return (
<TouchableCircle {...{onPress}} {...rest}>
  <Text>{props.text}</Text>
</TouchableCircle>
);
                                                                                              };

export {CircleButton};

After this is needed to import into ./src/styles/Generics/index.tsx

import Text from "./texts";
import Button, { CircleButton } from "./Buttons";

export { Text, Button, CircleButton};

Themes

The themes are configurated for consume and object with the specific caracteristics and made more easy edit and add new themes

./src/styles/ |----index.tsx |----Constants/Colors.tsx

In the file Colors in src/styles/Constants/Colors.tsx we can see the structure for blank&white theme in an object like:

var Colors:any = {
  dark: {
    textColor: "white"
  },
  white: {
    textColor: "gray"
  }
};

export default Colors;

we can see the parameter textColor inside the object dark and white this paramenter is use in the styles for example in src/Styles/Atoms/Atom1/index.tsx:

import React from "react";
import { FontSize, Colors } from "../../Constants";
import Styled from "styled-components";

const Text = Styled.h4`
@media screen and (max-width:1020px){
 ${FontSize.small}
}
@media screen and (max-width:820px){
  ${FontSize.mini}
}

color: ${props => Colors[props.theme].textColor} ; <------- this is the use for the specific parameter from Colors Object
`;

const TextC = (props: any) => {
  return <Text theme="white"> props.text</Text>; 
};

export default TextC;

if we need add a new value is extricted add in the objects for theme or this can take the default style for html

Hooks

Hooks can controlle the state like redux for local components, in this template for widget can control the state, simulating an global state like redux.

Structure

Hooks is similar to redux in the reducer and the actions this data can be change for dispatchs and controlled by actions

The folder Structur for this template for widgets is the next:

---- src/ ------- Hooks/ --------- index.tsx --------- Hooks.Actions.tsx --------- Hooks.Reducer.tsx

In src/Hooks/index.tsx can found the initial state for the widget In the sr/Hooks/Hooks.Actions.tsx can found the actions for dispatch actions to the reducer from any component how called In the src/Hooks/Hooks.Reducer.tsx can found the Reducer how launch the updates to the State

Libraries Added

References