Skip to content

Instantly share code, notes, and snippets.

View jepser's full-sized avatar

Jepser Bernardino jepser

View GitHub Profile
@jepser
jepser / autopr-dependencies.sh
Created March 12, 2018 22:07
Create PR to the projects that depend on your library
# Library repository
WP_SHARED_MODULES=Typeform/wp-shared-modules
# List of repositories in which you want to create a PR
REPOSITORIES=(public-website a-little-more-human helpcenter)
# Returns the name of the last tag of the repo that is being updated
get_latest_release() {
curl --silent -u ${GH_USER}:${GH_TOKEN} "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
@jepser
jepser / Typeform-README.md
Last active March 16, 2018 12:15
Readme template for Typeform frontend projects

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Requirements

@jepser
jepser / responsive-styled-components.js
Last active May 18, 2019 16:11
Implementation of responsive styled components
// helpers.js
/**
* Generate a valid structure for responsive configuration for a component
* @param {object} props props received from the component
* @param {array} baseProps list of props to be validated
*
* @returns a structured object with the props for each media query
*/
export const generateResponsiveProps = (props, baseProps) => {
// from the breakpoints registered check which props exists
import { Col } from 'super-library'
// either like this
<Col md={5} offsetMd={1} />
// or this
<Col md={{ size: 5, offset: 1 }} />
const Spacer = ({
top, left, bottom, right, children,
}) => {
return (
<Root
top={ top }
left={ left }
bottom={ bottom }
right={ right }
>
<MatchMedia query={BREAKPOINTS.md}>
 { matches => matches ? <UseThis /> : <UseOther /> }
</MatchMedia>
// for base usage
<Spacer bottom={2} left={2}>cool component here</Spacer>
// for responsive usage
<Spacer md={{ bottom: 2, left: 2 }} left={1}>cool component here</Spacer>
const Spacer = ({
top, left, bottom, right, children, sm, md, lg, xl,
}) => {
return (
<Root
top={ top }
left={ left }
bottom={ bottom }
right={ right }
sm={sm}
const Root = styled.div`
//…
${mediaqueries.md`
//specific rules for this break point
`
`
/**
* Generate a valid structure for responsive configuration for a component
* @param {object} props props received from the component
* @param {array} baseProps list of props to be validated
*
* @returns a structured object with the props for each media query
*/
export const generateResponsiveProps = (props, baseProps) => {
// from the breakpoints registered check which props exists
const shapedPropsWithMq = Object.keys(BREAKPOINTS).reduce(