Skip to content

Instantly share code, notes, and snippets.

View srph's full-sized avatar
🛠️
Building @Stride-Labs Frontend

Kier Borromeo srph

🛠️
Building @Stride-Labs Frontend
View GitHub Profile
<SomeComponent.Footer>
{(slotProps) =>
<div>{slotProps.loading ? 'Loading...' : null}</div>
}
</SomeComponent.Footer>
@srph
srph / gist:65b56ce893705cc98e6334d9ef0099b5
Created July 1, 2018 06:42
Google Spreadsheets: Count columns of specific color
// Needs Google Spreadsheets PowerTools
=COUNTA(valuesByColor("#f4cccc", "", B4:E4))
@srph
srph / index.js
Last active June 18, 2018 03:36
JS: Organizing styled-components
const styling = {
Container: style.div`
padding: 16px;
${props => props.isBig && css`
padding: 32px;
`}
`,
Heading: styled.div`
display: flex;
`,
@srph
srph / index.js
Last active May 29, 2018 11:26
JS: X in Square coding challenge
// ++++++++++++++++
// ++ ++
// + + + +
// + + + +
// + + + +
// + + + +
// + + + +
// + ++ +
// + + + +
// + + + +
const layout = (
<BaseLayout>
<BaseLayout.Header>
<h1>Here might be a page title</h1>
</BaseLayout.Header>
<BaseLayout.Body>
<p>A paragraph for the main content.</p>
<p>And another one.</p>
</BaseLayout.Body>
function Header() {
return null
}
function Body() {
return null
}
function Footer() {
return null
<base-layout>
<template slot="header">
<h1>Here might be a page title</h1>
</template>
<p>A paragraph for the main content.</p>
<p>And another one.</p>
<template slot="footer">
<p>Here's some contact info</p>
<div class="container">
<header>
<slot name="header"></slot>
</header>
<main>
<slot></slot>
</main>
<footer>
<slot name="footer"></slot>
</footer>
<MyPopover open={this.state.open}
onOpen={this.handleOpen}
onClose={this.handleClose}
renderButton={<button>Click!</button>}>
<h1>My Popover!!</h1>
</MyPopover>
@srph
srph / index.js
Last active May 23, 2018 02:32
JS: Array.from that works without .length
/**
* Converts an array-like object into an array.
* Array.from doesn't work if an object doesn't have a "length" property.
* e.g., Array.from({ 0: 1 }) doesn't work; Array.from({ 0: 1, length: 1 }) does.
*/
function arrayFrom (obj: {}): Array<*> {
return Object.keys(obj).reduce((set: Array, key: string) => {
return [...set, obj[key]]
}, [])
}