Skip to content

Instantly share code, notes, and snippets.

View koss-lebedev's full-sized avatar

Konstantin koss-lebedev

View GitHub Profile
import * as React from "react"
import { Stack, addPropertyControls, ControlType } from "framer"
import { ContactItem } from "./canvas"
type Props = {
count: number
}
export function ContactList({ count = 5 }: Props) {
const [users, setUsers] = React.useState([])
type Props = HTMLAttributes<HTMLInputElement>
const CustomInput = ({ onChange, ...props }: Props) => {
const handleChange = (event) => {
/// ... some logic
onChange(event)
}
return <input {...props} onChange={handleChange} />
}
type Props = HTMLAttributes<HTMLInputElement> & {
onUpdate: (value: string) => void
}
const CustomInput = ({ onUpdate, ...props }: Props) => {
const onChange = (event) => {
/// ... some logic
onUpdate(event.target.value)
}
type Props = InputHTMLAttributes<HTMLInputElement>
const CustomInput = (props: Props) => {
// ...some additional logic
return <input {...props} />
}
type Props = { value: string; onChange: () => void }
const CustomInput = ({ value, onChange }: Props) => {
// ...some additional logic
return <input value={value} onChange={onChange} />
}
type Props = InputHTMLAttributes<HTMLInputElement>
const Input = (props: Props) => { /* ... */ }
const CharCountInput = (props: Props) => {
return (
<div>
<Input {...props} />
<span>Char count: {props.value.length}</span>
</div>
import styled from 'styled-components'
const Button = (props) => { /* ... */ }
const StyledButton = styled(Button)`
border: 1px solid black;
border-radius: 5px;
`
const App = () => {
const Message = ({ text }) => {
return (
<div>
<p>{text}</p>
</div>
)
}
const Message = ({ text, imageUrl }) => {
return (
<div>
{imageUrl && <img src={imageUrl} />}
{text && <p>{text}</p>}
</div>
)
}
const Message = ({ text, imageUrl, audioUrl }) => {
if (audioUrl) {
return (
<div>
<audio controls>
<source src={audioUrl} />
</audio>
</div>
)
}