Skip to content

Instantly share code, notes, and snippets.

View SahanAmarsha's full-sized avatar
🏠
Working from home

Sahan Amarsha SahanAmarsha

🏠
Working from home
View GitHub Profile
import { DataStore } from "@aws-amplify/datastore";
import { Car } from "./models";
...
const saveCar = async () => {
try {
await DataStore.save(
new Car({
name: name,
@SahanAmarsha
SahanAmarsha / App.js
Last active January 24, 2022 19:44
App.js final version
import { AddCar, NavBar, NewCars } from "./ui-components";
import { Divider, withAuthenticator } from "@aws-amplify/ui-react";
import { DataStore } from "@aws-amplify/datastore";
import { Car } from "./models";
import { useState } from "react";
import "./App.css";
// retrieving signOut function, and user data
function App({ user, signOut }) {
const [name, setName] = useState("");
@SahanAmarsha
SahanAmarsha / App.tsx
Last active March 17, 2022 09:14
App.tsx renders MUI components
import React from "react";
import { Box, CssBaseline, Paper, Typography } from "@mui/material";
function App() {
return (
<div>
<CssBaseline />
<Box
height="100vh"
display="flex"
@SahanAmarsha
SahanAmarsha / Custom_Theme.txt
Created March 4, 2022 17:35
Define custom theme
// define theme
const theme = createTheme({
palette: {
primary: {
light: '#63b8ff',
main: '#0989e3',
dark: '#005db0',
contrastText: '#000',
},
secondary: {
@SahanAmarsha
SahanAmarsha / App.tsx
Last active March 17, 2022 09:18
App.tsx after adding custom theme
import React from "react";
import {
Box,
CssBaseline,
Paper,
ThemeProvider,
Typography,
} from "@mui/material";
import { createTheme } from "@mui/material/styles";
@SahanAmarsha
SahanAmarsha / Home.tsx
Last active March 13, 2022 09:17
Home Page Component
// src/pages/Home.tsx
import React, {ReactElement, FC} from "react";
import {Box, Typography} from "@mui/material";
const Home: FC<any> = (): ReactElement => {
return (
<Box sx={{
flexGrow: 1,
backgroundColor: 'whitesmoke',
@SahanAmarsha
SahanAmarsha / routes.ts
Created March 15, 2022 17:02
Define routes in our React App
// src/routes.ts
// pages
import Home from "./pages/Home";
import About from "./pages/About";
import Products from "./pages/Products";
// other
import {FC} from "react";
@SahanAmarsha
SahanAmarsha / App.tsx
Last active March 17, 2022 09:59
App.tsx Iterating Through Routes
// src/App.tsx
import React from "react";
import { Box, CssBaseline, ThemeProvider } from "@mui/material";
import { createTheme } from "@mui/material/styles";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import { routes as appRoutes } from "./routes";
function App() {
@SahanAmarsha
SahanAmarsha / Navbar.tsx
Last active March 15, 2022 18:10
Example Navbar Component
// src/components/Navbar.tsx
import React, { FC, ReactElement } from "react";
import {
Box,
Link,
Container,
IconButton,
Menu,
MenuItem,
@SahanAmarsha
SahanAmarsha / Footer.tsx
Created March 15, 2022 18:00
Example Footer component.