Skip to content

Instantly share code, notes, and snippets.

View yarigpopov's full-sized avatar

Iaroslav Popov yarigpopov

View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
filter: 'coo',
chores: [
{ name: 'cook', done: true },
{ name: 'clean', done: true },
{ name: 'write more unit tests', done: false }
],
@yarigpopov
yarigpopov / cap.js
Last active January 11, 2020 18:17
'CHRIS NG, ALON BUKAI, JESSICA JORDAN, ANNE-GREETH VAN HERWIJNEN, ISAAC LEE, JARED GALANIS, AMY LAM'
.split(',')
.map(i=>i.toLowerCase()
.split(' ')
.map(name=>name.charAt(0).toUpperCase() + name.slice(1))
.join(' '))
.join(',')
@yarigpopov
yarigpopov / view.tsx
Created February 10, 2020 18:37 — forked from gaperton/view.tsx
React Views on Fitbit
import React from 'react'
import { render, loop, Rotate } from './tools';
const App = () => (
<svg>
<section x="50%" y="50%">
<section width="95%" height="95%">
{ loop( 1, 12, i =>
<Mark angle={ i * 30 } length={10} />
)}
@yarigpopov
yarigpopov / RadioImageForm.RadioInput.js
Last active October 11, 2021 11:27
RadioImageForm.render() и RadioImageForm.RadioInput
export class RadioImageForm extends React.Component<Probs, State> {
// ...
render(): React.ReactElement {
const { currentValue, onChange, defaultValue } = this.state;
return (
<RadioImageFormWrapper>
<form>
{
React.Children.map(this.props.children,
// ...
function App() {
const [value, setValue] = React.useState(null);
const onChange = (value: string): void => {
setValue(value);
};
return (
<div className="container App">
<Banner
const RadioImageFormContext = React.createContext({
currentValue: '',
defaultValue: undefined,
onChange: () => { },
});
RadioImageFormContext.displayName = 'RadioImageForm';
static RadioInput = ({ label, value, name, imgSrc }: RadioInputProps) => (
<RadioImageForm.Consumer>
{({ currentValue, onChange }) => (
<label className="radio-button-group" key={value}>
<input
type="radio"
name={name}
value={value}
aria-label={label}
onChange={onChange}
interface State {
data: IDog;
status: Status;
error: Error;
}
const initState: State = { status: Status.loading, data: null, error: null };
const DogDataProviderContext = React.createContext(undefined);
DogDataProviderContext.displayName = 'DogDataProvider';
export function useDogProviderState() {
const context = React.useContext(DogDataProviderContext);
if (context === undefined) {
throw new Error('useDogProviderState must be used within DogDataProvider.');
}
return context;
}
function App() {
return (
<Router>
<div className="App">
{/* The data provider component responsible
for fetching and managing the data for the child components.
This needs to be at the top level of our component tree.*/}
<DogDataProvider>
<Nav />
<main className="w-full py-5 mx-auto text-center text-white md:py-20 max-w-screen-xl">