All Projects β†’ rmariuzzo β†’ shorted-theme

rmariuzzo / shorted-theme

Licence: MIT license
Shorted theme references for Styled Components.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to shorted-theme

Goober
πŸ₯œ goober, a less than 1KB πŸŽ‰ css-in-js alternative with a familiar API
Stars: ✭ 2,317 (+17723.08%)
Mutual labels:  styled-components, styled
react-styled-floating-label
Floating label component which works with any HTML input
Stars: ✭ 33 (+153.85%)
Mutual labels:  styled-components, styled
jss-material-ui
A enhanced styling engine for material-ui
Stars: ✭ 15 (+15.38%)
Mutual labels:  styled-components, styled
foliage
πŸƒ Style your components with performance
Stars: ✭ 29 (+123.08%)
Mutual labels:  styled-components, styled
nebuchadnezzar
on the way to cleanest react architechture
Stars: ✭ 15 (+15.38%)
Mutual labels:  styled-components, styled
Styled-Responsive-Media-Queries
Responsive Media Queries for Emotion styled or styled-components β€” Standard size from Chrome DevTools.
Stars: ✭ 33 (+153.85%)
Mutual labels:  styled-components, styled
youtube-unofficial
Access parts of your account unavailable through normal YouTube API access.
Stars: ✭ 33 (+153.85%)
Mutual labels:  utility
getify
A utility to grab nested values from objects.
Stars: ✭ 12 (-7.69%)
Mutual labels:  utility
rhq
Manages your local repositories
Stars: ✭ 48 (+269.23%)
Mutual labels:  utility
juggle-and-drop
Juggle all your tasks! (A fullstack Kanban app w/ drag-and-drop) πŸ€Ήβ€β™‚οΈ
Stars: ✭ 38 (+192.31%)
Mutual labels:  styled-components
RawDiskLib
A C# Library to read from raw sectors of a disk
Stars: ✭ 38 (+192.31%)
Mutual labels:  utility
cobra-policytool
Manage Apache Atlas and Ranger configuration for your Hadoop environment.
Stars: ✭ 16 (+23.08%)
Mutual labels:  utility
React-Redux-Enterprise
A React-Redux boilerplate for enterprise/large scaled web applications
Stars: ✭ 77 (+492.31%)
Mutual labels:  styled-components
PathCleaner
Cleanup tool for polluted PATH environment variable
Stars: ✭ 18 (+38.46%)
Mutual labels:  utility
mediocre-pictures
Helping you take mediocre pictures, hands-free. πŸ“·πŸ™†πŸ»πŸ™…πŸΎπŸ’πŸΌπŸ“Έ
Stars: ✭ 16 (+23.08%)
Mutual labels:  styled-components
RaycastVisualization
This asset allows users to view raycasts as the user fires them.
Stars: ✭ 61 (+369.23%)
Mutual labels:  utility
global-upvote
A progressive web app that provides top voted stories across the web, summarized and updated every sixty seconds.
Stars: ✭ 25 (+92.31%)
Mutual labels:  styled-components
molecule
βš›οΈ –  – βš›οΈ Boilerplate for cross platform web/native react apps with electron.
Stars: ✭ 95 (+630.77%)
Mutual labels:  styled-components
actlist-plugin
πŸ”§ Actlist Plugin library to development and debugging.
Stars: ✭ 14 (+7.69%)
Mutual labels:  utility
character
tool for character manipulations
Stars: ✭ 26 (+100%)
Mutual labels:  utility

shorted-theme - Shorted theme references for Styled Components.

Comparison: before and after




Features

Installation

npm i shorted-theme

Usage

import styled from 'styled-components'
import shorted from 'shorted-theme'

const theme = {
  colors: {
    primary: 'red',
    secondary: 'blue'
  },
  fontFamily: '"Roboto", sans-serif',
  fontSizes: {
    small: 12,
    regular: 14,
    large: 18
  }
}

const t = shorted(theme) // πŸ‘ˆ short your theme then use everywhere.

const Button = styled.button`
  color: ${t.colors.primary};
  color: ${t.colors.primary};
  font-family: ${t.fontFamily};
  font-size: ${t.fontSizes.regular};
`

TypeScript Support

shorted-theme use all your typings.

Suggestion

You can destructure the shorted theme object. That way you can reference direct children properties instead of a root object.

const { colors, fontFamily, fontSizes } = shorted(theme)

const Button = styled.button`
  color: ${colors.primary};
  color: ${colors.primary};
  font-family: ${fontFamily};
  font-size: ${fontSizes.regular};
`

Limitations

shorted-theme is useful for writing less when referencing theme values. However, it can't be used in expressions. For example:

// THIS WILL NOT WORK
const Button = styled.button`
  padding: ${t.padding.default * 10};
`

Instead you should use the function expression:

const Button = styled.button`
  padding: ${(props) => props.theme.padding.default * 10};
`

Development

  1. Clone this repository.
  2. Install dependencies: npm i.
  3. Run it locally: npm start or ./src/bin.js

Tests

npm run test

Releases

Releases are triggered by npm version and handled by GitHub Actions.




Made with β™₯ by @rmariuzzo
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].