Skip to content

Instantly share code, notes, and snippets.

@Jon20111
Jon20111 / eslintrc-and-jsx
Created September 14, 2021 01:45
jsx-a11y rule examples.
//.eslintrc.json
{
"env": {
"browser": true,
"es2021": true //not listed in documentation
},
"extends": [
"plugin:jsx-a11y/recommended"
],
"parserOptions": {
@Jon20111
Jon20111 / custom-text-field.styles.ts
Created August 18, 2020 03:43
Material-UI example styling
import { makeStyles } from '@material-ui/styles';
import { Theme } from '@material-ui/core';
export const useStyles = makeStyles((theme: Theme) => ({
parentForm: {
backgroundColor: '#C0C0C0'
},
customInput: {
margin: 12,
'&$disabled': {
@Jon20111
Jon20111 / wave-box-sides.txs
Last active July 23, 2020 19:03
The sides of an svg wave box
const calculateTop = useCallback(
point => {
const xyPoint = {
x: paddingOffset + point,
y: paddingOffset - pathFunction(point)
};
return ["L", xyPoint.x, xyPoint.y].join(" ");
},
[paddingOffset, pathFunction]
);
columns={[
{
title: "Name",
field: "name",
headerStyle: {
backgroundColor: "green"
}
},
...
options={{
headerStyle: {
backgroundColor: '#01579b',
color: '#FFF'
}
}}
components={{
Action: props => (
<Button
onClick={event => props.action.onClick(event, props.data)}
color="primary" variant="text"
style={{ textTransform: "none" }}
size="small"
>
Save
</Button>
actions={[
{
icon: () => <SaveIcon />,
tooltip: "Save User",
onClick: (event, rowData) => alert("You saved " + rowData.name)
}
]}
@Jon20111
Jon20111 / basic material-table
Created July 18, 2020 01:23
basic material-table
import React, { useState } from "react";
import "./styles.css";
import MaterialTable from "material-table";
export default function App() {
const [data, setData] = useState([
{ name: "Jon", job: "Software Dev", age: 29 }
]);
return (
<div className="App">
<h1>Material-Table Demo</h1>
@Jon20111
Jon20111 / material-table-wrapper.tsx
Created July 17, 2020 15:41
Material-Table example
import React, { FC, useState } from "react";
import MaterialTable from "material-table";
import DeleteIcon from "@material-ui/icons/Delete";
import SearchIcon from "@material-ui/icons/Search";
import SaveIcon from "@material-ui/icons/Save";
import { Button } from "@material-ui/core";
import { useStyles } from './material-table-wrapper.styles';
interface Column {
@Jon20111
Jon20111 / material-ui-override.tsx
Created May 22, 2020 18:34
A demonstration of how to override the default Material UI component style using useStyles
import React, { FC, useMemo } from 'react';
import { TextField, withStyles } from '@material-ui/core';
import { useStyles } from './form.styles';
export const Form: FC = () => {
const classes = useStyles();
const StyledTextField = useMemo(
() => {
return withStyles({
root: {