solui
  • Dapps
  • Getting Started
  • Docs
  • Community

@solui/styles

Styling utilities for solUI:

  • Base theme and colour scheme for the website and CLI frontend.
  • Layout utilities, including responsive breakpoints.
  • Font management.
  • Styling fragments for use with styled components.

Installation

npm install @solui/styles

Example usage

Asynchronously loading and using fonts, along with theming system:

const React = require('react')
const styled = require('@emotion/styled')
import { ThemeProvider } from 'emotion-theming'
const { loadFonts, getTheme } = require('@solui/styles')

const CustomDiv = styled.div`
  ${({ theme }) => theme.font('body')};
  color: ${({ theme  }) => theme.bodyTextColor};
`
export default class MyApp extends React.Component {
  componentDidMount () {
    if (typeof window !== 'undefined' && !!window.document) {
      loadFonts({
        body: {
          name: 'Roboto',
          weights: {
            thin: 100,
            regular: 400,
            bold: 700,
          },
        },
      }, window.document).then(
        () => this.forceUpdate(),
        err => console.error(err)
      )
    }
  }

  render () {
    return (
      <ThemProvider theme={getTheme()}>
        <CustomDiv>hello world!</CustomDiv>
      </ThemeProvider>
    )
  }
}

Read full documentation.

## License

Copyright 2019 solUI Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1

Default theme.

Type: Object

media

Responsive layout utilities

Type: Object

media.maxWidth

Maximum content width as a CSS dimension.

Type: String

media.when

Generate media query.

Parameters

  • m Object Parameters

Returns String

opacify

Set alpha value of given colour.

Parameters

  • c (String | Color) Color
  • a Number Alpha value between 0 and 1

Returns String New colour

loadFonts

Load fonts.

Parameters

Returns Promise

FontWeights

Type: Object

Properties

FontConfig

Type: Object

Properties

FontsConfig

Type: Object

Properties

flex

Generate flexbox CSS.

Parameters

  • p Object Parameters. (optional, default {})
    • p.direction String flex-direction. (optional, default 'column')
    • p.justify String justify-content. (optional, default 'center')
    • p.align String align-items. (optional, default 'center')
    • p.basis String flex-basis. (optional, default 'auto')
    • p.wrap String flex-wrap. (optional, default 'nowrap')

Returns String

absoluteCover

Generate CSS to fully cover parent.

Returns String

childAnchors

Generate CSS for child anchors.

Parameters

  • p Object Parameters
    • p.textColor
    • p.bgColor (optional, default 'transparent')
    • p.hoverTextColor
    • p.hoverBgColor
    • p.borderBottomColor
    • p.selected
    • p.extraStyles

Returns String

smoothTransitions

Generate CSS for smooth animations.

Returns String

boxShadow

Generate CSS for box shadow.

Parameters

Returns String

buttonStyles

Generate CSS for button styles.

Parameters

  • p Object Parameters
    • p.theme
    • p.disabled
    • p.buttonDisabledBgColor
    • p.buttonDisabledTextColor
    • p.buttonDisabledBorderColor
    • p.buttonBgColor
    • p.buttonTextColor
    • p.buttonBorderColor
    • p.buttonHoverBgColor
    • p.buttonHoverTextColor
    • p.buttonHoverBorderColor
    • p.buttonShadowColor

Returns String

resetStyles

Reset stylesheet.

Type: EmotionCss

getTheme

Get a theme.

Parameters

  • s Number? Theme number (default is latest version theme). (optional, default themes.length-1)

Returns Object Theme object.

getNumThemes

Get number of themes.

Returns Number