New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pcln-design-system

Package Overview
Dependencies
Maintainers
1
Versions
544
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pcln-design-system

Priceline Design System

  • 1.0.0-0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-38.22%
Maintainers
1
Weekly downloads
 
Created
Source

Priceline Design System

Build Status Coverage

https://pricelinelabs.github.io/design-system/

Motivation

In order to create a consistently great experience for our users, the design system is meant to be the single source of truth for user interface standards for both designers and developers.

Built off of the work of previous efforts, this project intends to consolidate those ideas into a living, well-documented, and growing system.

Goals

The core goals of this project are to:

  • Speed up design and development velocity
  • Help create consistent, beautiful, and usable UI in our applications
  • Promote best practices for accessibility, internationalization, and responsive web design

We hope to accomplish these goals by:

  • Reducing the number of decisions needed when iterating on UI
  • Reducing the amount of code duplication in our apps
  • Serving as the standard for Priceline.com's visual language
  • Providing easy-to-use and extensible components for anyone to consume

ThemeProvider

To use the design system in a React app, wrap the root component with the ThemeProvider. This will set typographic defaults and pass the theme as context, which allows styled-components to consume the theme.

import { ThemeProvider } from 'pcln-design-system'

const App = props => (
  <ThemeProvider>
    <h1>Hello</h1>
  </ThemeProvider>
)
// Usage with styled-components
import styled from 'styled-components'

const Section = styled.section`
  background-color: ${props => props.theme.blue};
`

Primitive UI Components

The preferred way of using the design system in a React application is with UI primitives. With effective use of the UI primitives, you can reduce the need to write custom CSS in your application.

import React from 'react'
import { ThemeProvider, Box, Text } from 'pcln-design-system'

const App = props => (
  <ThemeProvider>
    <Box p={3}>
      <Text>Hello</Text>
    </Box>
  </ThemeProvider>
)

<Text />

Use the <Text /> component to control font size, weight, alignment, and color.

// Font size 4 on the typographic scale
<Text fontSize={4} />

// Center aligned
<Text align='center' />

// Bold weight
<Text bold />

// All-caps
<Text caps />

// Blue text from the color palette
<Text color='blue' />
PropTypeDescription
fontSizenumber or stringSets font size based on the typographic scale
alignstringSets the text-align property
boldbooleanSets font-weight: props.theme.bold
capsbooleanSets styles for all-caps type treatments
colorstringSets color based on the theme's color palette
mnumber, string, or arraySets margin based on the theme.space scale
mtnumber, string, or arraySets margin-top
mrnumber, string, or arraySets margin-right
mbnumber, string, or arraySets margin-bottom
mlnumber, string, or arraySets margin-left
mxnumber, string, or arraySets margin-left and margin-right
mynumber, string, or arraySets margin-top and margin-bottom

By default, the <Text /> component renders a <div> element. To use a <span> or <p> element, use the following:

<Text.span>This is a span element</Text.span>
<Text.p>This is a p element</Text.p>

<Box />

Use the <Box /> component to control width, margin, padding, and color.

// 50% width
<Box width={1/2} />

// Padding of `theme.space[3]` (16px)
<Box p={3} />

// Margin of `theme.space[2]` (8px)
<Box m={2} />

// Color blue from the theme's color palette
<Box color='blue' />

// Background color green from the theme's color palette
<Box bg='green' />
PropTypeDescription
widthnumber, string, or arraySets the width of the element
colorstringSets color based on the theme's color palette
bgstringSets background-color based on the theme's color palette
mnumber, string, or arraySets margin based on the theme.space scale
mtnumber, string, or arraySets margin-top
mrnumber, string, or arraySets margin-right
mbnumber, string, or arraySets margin-bottom
mlnumber, string, or arraySets margin-left
mxnumber, string, or arraySets margin-left and margin-right
mynumber, string, or arraySets margin-top and margin-bottom
pnumber, string, or arraySets padding based on the theme.space scale
ptnumber, string, or arraySets padding-top
prnumber, string, or arraySets padding-right
pbnumber, string, or arraySets padding-bottom
plnumber, string, or arraySets padding-left
pxnumber, string, or arraySets padding-left and padding-right
pynumber, string, or arraySets padding-top and padding-bottom
Responsive Widths

The width prop accepts an array value to set different widths at different breakpoints with a mobile-first approach.

<Box
  width={[
    1,    // Sets width 100% at the smallest breakpoint
    1/2,  // Sets width 50% at the next breakpoint
    1/4,  // Sets width 25% at the next breakpoint
  ]}
/>

Theme

The theme style constants should be used whenever low-level access to font sizes, margin, padding, media queries, and colors are needed.

import {
  theme,
} from 'pcln-design-system'

// or
import {
  colors,
  mediaQueries,
  fontSizes,
  space
} from 'pcln-design-system'

Colors

import { colors } from 'pcln-design-system'

colors.blue // '#0a84c1'

Font Sizes

import { fontSizes } from 'pcln-design-system'

fontSizes[2] // 16

The theme includes a typographic scale as the fontSizes array. Use these values whenever declaring a font-size in CSS.

Spacing Scale

The space array should be used whenever declaring margin or padding values.

import { space } from 'pcln-design-system'

space[0] // 0
space[1] // 4
space[2] // 8
space[3] // 16
space[4] // 32
space[5] // 64
space[6] // 128

MIT License

FAQs

Package last updated on 03 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc