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

@old-keg-hub/keg-components

v9.5.1

Published

* Base UI Components for the Keg Core and Tap extensions

Downloads

2

Readme

Keg Components

  • Base UI Components for the Keg Core and Tap extensions

Add to your project

  yarn add @keg-hub/keg-components
  npm install @keg-hub/keg-components

Developer setup

  • git clone https://github.com/simpleviewinc/keg-hub.git ~/keg-hub
  • cd ~/keg-hub/repos/keg-components
  • yarn install
  • yarn sb - local storybook
  • yarn sb:native - native local storybook
  • yarn sb:web - web local storybook
  • yarn format - formats your code based on the config set in configs/eslint.config.js && configs/prettier.config.js
  • yarn eslint:watch - watches any code change for any lint errors

Theming

Keg Components leverages re-theme for dynamic theming across platforms and viewport sizes

Theme objects

  • For new components, create and export your theme objects in src/theme/components

Using themes in components

  • Use the useThemePath hook:

    import { useThemePath } from '../../hooks'
    
    const FooBar = (props) => {
      // theme from `src/theme/components/fooBar.js`
      const fooBarTheme = useThemePath('fooBar')
      return (
        <View style={fooBarTheme.main}>
          ...
        </View>
      )
    }

Conventions

Folder structure:

  • if you are creating a function that has a different implementation for native
    • DO
      • place them in a folder with the same name as the export
      • add an alias for them in the /configs/aliases.json file
      • add a index.js exporting the alias
         /src/components
            /linearGradient
               linearGradient.js
               linearGradient.native.js
               index.js   
                      
          // /configs/aliases.json
          {
            ...other aliases,
            "KegLinearGradient": "src/components/linearGradient/linearGradient${platform}.js",
          }
      
          // /src/components/linearGradient/index.js
          export * from 'KegLinearGradient'
      

Every component implemented in keg-components that has a theme should define main and content styles:

/* src/theme/components/sampleButton.js */
export const sampleButton = {
  main: { ... },
  content: { ... }
}
  • main: the root styles of the component
  • content: the styles for content in the component
  • Example: a simple Button component's main style would theme its root View component, whereas the content style themes its inner Text component:
    /* src/components/button/sampleButton.js */
    export const SampleButton = (props) => {
      const buttonTheme = useThemePath('sampleButton', props.style)
      return (
        <View style={buttonTheme.main}>
          <Text style={buttonTheme.content}>
            { props.text }
          </Text>
        </View>
      )
    }

Components sometimes import/consume other keg-components and then need to style those imported components within their styling context. These styles should be defined in the consumer's theme object

  • Example: a button with an icon
/* src/theme/components/iconButton.js */
export const iconButton= {
  main: { ... },
  content: { ... },
  icon: {
    main: { ... },
    content: { ... }
  }
}

Use size keys (e.g. $small, $medium, etc.) and platform keys (e.g. $native, $web, $all, etc.) to wrap style properties only. This ensures that the shape of the theme object remains constant across all platforms and viewport sizes.

  • DON'T do this:
export const button = {
  $web: { 
    main: {
      backgroundColor: 'coral'
    },
  },
  $native: {
    main: { 
      backgroundColor: 'green' 
    },
    content: { 
      margin: 15 
    }
  }
}
  • DO this:
export const button = {
  main: {
    $native: { 
      backgroundColor: 'green'
    },
    $web: { 
      backgroundColor: 'coral'
    }
  },
  content: {
    $native:  { 
      margin: 15
    }
  }
}
  • In the first case, the theme object would not have the content styles on the $web platform, making it inconsistent with $native

Icons

  • TODO - add info on adding SVG's

Accessibility

  • Mapping of accessibilityRole prop value to Web Element
  • Example => <Link accessibilityRole='link'> => <a role='link'>
  article: 'article',
  banner: 'header',
  complementary: 'aside',
  contentinfo: 'footer',
  form: 'form',
  link: 'a',
  list: 'ul',
  listitem: 'li',
  main: 'main',
  navigation: 'nav',
  region: 'section',
  adjustable: 'slider',
  button: 'button',
  // Heading mapping leverages the `aria-level` prop to determine the heading element
  // Example <Text accessibilityRole='header' aria-level='1' > => <h1>
  header: 'heading',
  image: 'img',
  link: 'link',
  none: 'presentation',
  search: 'search',
  summary: 'region',

Create Element

  • This library exports a createElement method
  • This method allows create custom native elements per platform, for needs such as:
    • Defining className when on a web platform
    • Overwriting the Text component, but still taking advantage of the accessability props
    • TODO: Give more examples