This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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(',') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> | |
)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
function App() { | |
const [value, setValue] = React.useState(null); | |
const onChange = (value: string): void => { | |
setValue(value); | |
}; | |
return ( | |
<div className="container App"> | |
<Banner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RadioImageFormContext = React.createContext({ | |
currentValue: '', | |
defaultValue: undefined, | |
onChange: () => { }, | |
}); | |
RadioImageFormContext.displayName = 'RadioImageForm'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function useDogProviderState() { | |
const context = React.useContext(DogDataProviderContext); | |
if (context === undefined) { | |
throw new Error('useDogProviderState must be used within DogDataProvider.'); | |
} | |
return context; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |