• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Buffer's shared collection of React UI components πŸ€œπŸ€›

Buffer Components

Build Status

A shared set of UI Components using React and CSS Modules.

Demo: https://bufferapp.github.io/buffer-components/

To use this in your project start at the usage section. If you'd like to add to this library skip to component development.

Usage

Install the package and save the exact version:

npm install @bufferapp/components -SE

Now in your code you can import a specific component:

import Button from '@bufferapp/components/Button';

Requirements

For the component library you're required to use a few plugins and a valid Webpack config.

First, you'll need React installed (0.14 or newer):

npm i react react-dom -SE

In addition to your Babel configuration (not documented), you'll need the style-loader Webpack plugin:

npm i style-loader -SDE

Your Webpack config should use the proper config, here is an example:

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        loaders: [
          'style-loader',
        ],
      },
    ],
  },
};

Component Development

Quick Start

Install Node Modules

npm i

Start React Storybook

npm start

Open http://localhost:9001

Test

Run Linter And Test

npm run test

Run Test and watch for changes

npm run test-watch

Update Test Snapshots

npm run test-update

Note: only commit these if you have manually inspected them with a story

Component Anatomy

src/ # root
+-- MyComponent/ # component root
  `-- index.js # component display logic
  `-- story.js # storybook entry

Versioning

major.minor.patch

Considered patch release

Can upgrade without changes to the codebase

  • Add a component
  • Add a new prop to a component

Considered minor release

An upgrade would require a code change to work

  • Remove a component
  • Remove a prop

Considered major release

  • Major milestone achieved (i.e a complete set of components)
  • Complete re-skinning of components
  • Up for debate

FAQ

What is a component

In the current implementation components are all functional and stateless.

This means that UI is a function of state since we're using pure functions to build our views.

UI = f(state)

How do I determine the scope of a component

This is a tough question, it really depends. But as a general rule, a component should be simple enough to be reusable across multiple applications and be not much longer than 150 lines of code. This is a good one to seek advice if you're not sure.

What's the development workflow look like?

Note: this is a way to do this, but not necessarily the way to build components. For this workflow let's create a component called NewComponent.

  1. Create a branch with the name of the new component

Note: also make sure you're up to date

git checkout master
git pull -r
git checkout -b task/add-newcomponent
  1. Install dependencies and start the storybook
npm i && npm start

open http://localhost:9001 in your browser

  1. Create a NewComponent folder under src (see Component Anatomy)
src/
+-- NewComponent/
  1. Create a story for the NewComponent
src/
+-- NewComponent/
 `-- story.js

populate story.js with a default story

// story.js
import React from 'react';
import { storiesOf } from '@storybook/react';
import NewComponent from './index';

storiesOf('Card', module)
  .add('Default', () => (
    <NewComponent />
  ));

Now when you look at Storybook you should see a broken story (red screen)

  1. Implement your component
src/
+-- NewComponent/
 `-- story.js
 `-- index.js

populate index.js with the new component

import React from 'react';
import { calculateStyles } from '../lib/utils';

const NewComponent = ({ hovered }) =>
  <div
    style={calculateStyles({
      default:{
        background: 'green',
      },
      hovered: {
        background: 'red',
      }
    },{
      hovered, // key matches above style key and is activated when value is true
    })}
  >
    NewComponent
  </div>;

export default NewComponent;
  1. Run the test for the first time

It's important to note that this creates a snapshot of the component. All tests ran in the future will be tested against this snapshot to ensure they haven't changed.

npm t
  1. Commit it!
git add .
git commit -m "Add NewComponent"
git push -u origin task/add-newcomponent

At this point it's a good idea to generate a PR on github :)

How do I write tests for a component?

This automatically happens when you write stories. They are tested with jest snapshots under the hood.

Since components are functional and stateless we can use snapshot testing to get complete coverage.

You're verifying that each property change has the expected outcome in HTML.

The first time the test is run it generates a new snapshot. The second time it's checked against the snapshot.

How Do I Update A Snapshot

npm run test-update

How do determine what a component does?

There's a pattern you can follow

  1. Look at the Component.propTypes section
  • This is essentially the API of the component
  1. Look at the render function
  2. Look at any helper functions
  3. Ask one of the contributors :)

More Repositories

1

android-clean-architecture-boilerplate

An android boilerplate project using clean architecture
Kotlin
3,651
star
2

clean-architecture-components-boilerplate

A fork of our clean architecture boilerplate, this time using the Android Architecture Components
Kotlin
1,277
star
3

BufferTextInputLayout

A simple customised version of the TextInputLayout from the Android Design Support Library ⌨️
Java
983
star
4

android-clean-architecture-mvi-boilerplate

A fork of our clean architecture boilerplate using the Model-View-Intent pattern
Kotlin
978
star
5

AdaptableBottomNavigation

A simpler way for implementing the Bottom Navigation View on Android
Java
830
star
6

android-guidelines

Project Guidelines for the Android Buffer App
Shell
750
star
7

buffer-ios-image-viewer

The BFRImageViewer is a turnkey solution to present images within your iOS app πŸŽ‰!
Objective-C
399
star
8

clean-architecture-koin-boilerplate

A fork of our clean architecture boilerplate, this time using Koin
Kotlin
331
star
9

MultiActionSwipeHelper

An Android RecyclerView Swipe Helper for handling multiple actions per direction
Java
296
star
10

CounterView

A simple Android counter view for showing edittext character counts
Kotlin
176
star
11

Thumby

An Android video thumbnail picker
Kotlin
173
star
12

ReactivePlayBilling

An RxJava wrapper for the Google Play Billing Library
Kotlin
117
star
13

buzzer

A little buzzer app for running your own quizzes or game shows!
JavaScript
94
star
14

buffer-chrome

Buffer for Chrome lets you easily add great articles, pictures and videos to your Buffer and we automagically share them for you through the day!
JavaScript
66
star
15

SocialLinkify

An Android library for linking @ mentions & Hashtags to their corresponding social network
Kotlin
65
star
16

BFRReorderTableView

The BFRTableReorder is an out of the box solution to add long press reordering to your ASDK apps
Objective-C
57
star
17

ui

✨ Buffer's UI Components library and Style Guide✨
TypeScript
51
star
18

old-diversity-dashboard

R
49
star
19

kiner

Python AWS Kinesis Producer with error handling and thread support.
Python
45
star
20

README

Welcome, friend! Here's an overview to our engineering team's documentation
Shell
43
star
21

sqs-worker-go

Go
38
star
22

code-of-conduct

Buffer's Employee Code of Conduct
36
star
23

diggdigg

DiggDigg is the floating all-in-one share bar for your WordPress website.
PHP
33
star
24

buffer-ios-sdk

Buffer iOS SDK
Objective-C
30
star
25

javascript-style-guide

Buffer's JavaScript style guide
24
star
26

Biscotti

A collection of Custom Actions and Matchers for Espresso Testing
Kotlin
23
star
27

buffer-blog-v2

Buffer Blog design starting July 2014
PHP
21
star
28

bootstrap-datepicker

Our own fork of eternicode's bootstrap datepicker that includes time selection.
21
star
29

buffer-extension-shared

Shared code between Buffer extensions
JavaScript
21
star
30

buffer-style

The Buffer Style Guide
JavaScript
20
star
31

EKG

Kubernetes Health And Liveness Check
JavaScript
20
star
32

android-components

Shared components for Buffer Android apps
Kotlin
19
star
33

carden

Service to save MongoDB Change Streams (oplog) records into Big Query
Python
19
star
34

buffer-php-style-guide

Buffer's PHP style guide
19
star
35

pylooker

A Python interface to Looker API
Python
16
star
36

lookerpy

A Python API client for Looker
Python
15
star
37

CustomViewIndicator

An Android ViewPager indicator that allows you to provide custom views for display
Kotlin
15
star
38

sharejs

Trigger the Buffer Share popup from any DOM element
JavaScript
14
star
39

Reactive-Pusher

An RxJava wrapper for the Pusher Java Library [Work in progress]
Kotlin
13
star
40

facebook-api-wrapper

Buffer's Facebook PHP API wrapper
PHP
13
star
41

churnado

Churn forecasting tool
R
13
star
42

buffer-redux-hover

Keep React component hover state in redux
JavaScript
12
star
43

omniauth-buffer2

Omniauth strategy to allow Ruby clients to easily use the Buffer API.
Ruby
12
star
44

k8s-jenkins-pipeline

Jenkins Pipeline Library for k8s Deployment Using Helm Chart
Groovy
11
star
45

stacklogging

Python logging integration with Google Cloud Stackdriver API.
Python
11
star
46

buffer-extensions

Main repo for extension code. Note: this has nested submodules
JavaScript
11
star
47

buffer-firefox

Buffer for Firefox
JavaScript
10
star
48

github-notify-client

Get system notifications when you get PRs assigned to you!
JavaScript
10
star
49

buffer-web-components

Buffer Dashboard Specific Components
JavaScript
10
star
50

buffer-sharekit

A Buffer plugin for your ShareKit sharing menu for iOS
Objective-C
9
star
51

rsdf

Some functions to help Pandas DataFrames communicate with Redshift
Python
9
star
52

twilio-to-slack

πŸ“²πŸ’¬ A simple app to forward SMS messages from a Twilio number to a Slack channel
JavaScript
9
star
53

restream

Replay Firehose Streams in Kinesis Streams!
Python
9
star
54

buffer-ruby-deprecated

Official Ruby API wrapper for Buffer
Ruby
9
star
55

dbt-bigquery-auditlog

Get an overview of all cost and performance data for your BigQuery project
9
star
56

BFRGIFRefreshControl

Objective-C
8
star
57

BufferSwiftKit

Swift based SDK to access the Buffer API. The main goal is to provide a simple and easy interface to use Buffer in your iOS apps.
Swift
8
star
58

micro-rpc

Async RPC microservices made easy
JavaScript
8
star
59

buffer-safari

Buffer for Safari
JavaScript
7
star
60

jquery-dragme

A super lightweight jQuery plugin for dragging elements using CSS3 Transforms
JavaScript
7
star
61

extender

Cross-Browser Extension library and build tool
Ruby
6
star
62

buffer-quality-dashboard

GitHub issue dashboard
JavaScript
6
star
63

css-style-guide

How we CSS at Buffer
6
star
64

kubesecret

A tool to manage secrets in kubernetes
JavaScript
6
star
65

tracking-plan-kit

Utilities for managing Buffer's Data Tracking Plan
Python
5
star
66

segment-config-api

A Python Wrapper for Segment's Config API
Python
4
star
67

buffer-talks

Bufferoo Talks - built on Jekyll and Remark
HTML
4
star
68

docker-demos

Intro to Docker: Images + Containers
Dockerfile
4
star
69

buffer-static-upload

πŸ“β†’β˜οΈπŸ€˜ Making it easy to upload your static assets
Go
4
star
70

aws-key-auditor

Get all keys from an AWS account and send an email if a key is getting old
JavaScript
4
star
71

app-shell

Buffer's shared App Shell for front-end applications
TypeScript
3
star
72

cerone

Extensible consumer made for applications using Amazon's Kinesis Python Client Library (KCL).
Python
3
star
73

mongoct

MongoDB Change Streams tracker.
Python
3
star
74

buffer-bot

DEPRECATED
CoffeeScript
3
star
75

buffer-scripts

⌨️ A collection of useful scripts for all sorts of manual tasks!
Shell
3
star
76

buffer-code-exercise-api

A small api server which will be used in the Buffer interview code exercise.
JavaScript
3
star
77

buffer-opensource

Buffer ❀️ Open Source. Static site generator for Buffer's Open Source Site (https://bufferapp.github.io/)
HTML
2
star
78

gprc-metrics-poc

gRPC-based Metrics Collection pipeline proof-of-concept monorepo
JavaScript
2
star
79

convoyslit

Streamlit app to quickly explore convoys models from BigQuery queries
Python
2
star
80

buffer-js-shutdown-helper

Shutdown your Express.js apps gracefully
JavaScript
2
star
81

buffer-icons

Custom Buffer fonts for all!
HTML
2
star
82

micro-rpc-client

Universal JS RPC Client https://github.com/bufferapp/micro-rpc/
JavaScript
2
star
83

helpscout-api

A Python interface to Helpscout's API
Python
2
star
84

stripe-pipeline

A simple data pipeline for Stripe API events to Redshift
Python
2
star
85

cricket

Your personal Jiminy Cricket when posting online.
Python
2
star
86

pipub

Pipe data from the command line to Google Pubsub.
Python
2
star
87

go-base-worker

Golang packages needed to build a consumers
Go
2
star
88

buffer-js-dragme

module for dragging components
JavaScript
2
star
89

streamlit-causal-impact

Streamlit app to run Causal Infence in your CSVs
Python
2
star
90

android-utils

Common utilities used in our android projects
Kotlin
2
star
91

manual-payments

R
2
star
92

bufferapp.github.io

Buffer's Development Driven Values
HTML
1
star
93

buffer-branding-2018

HTML
1
star
94

buffer-js-logger

Node.js logging for Buffer applications
JavaScript
1
star
95

buffer-update-converters

Convert statuses from Twitter, Facebook and Instagram into Buffer updates
PHP
1
star
96

php-bufflog

php logger for all PHP Buffer services
PHP
1
star
97

dd-tracing-logging-examples

JavaScript
1
star
98

buffer-js-request

JS interface to send requests – thin wrapper around fetch()
JavaScript
1
star
99

slack-channels

Analysis on Buffer's slack channels
Jupyter Notebook
1
star
100

buffer-standards

Standard configuration for shared packages/tools at Buffer
TypeScript
1
star