Skip to content

Instantly share code, notes, and snippets.

View mkirby's full-sized avatar

Matthew Robbins Kirby mkirby

View GitHub Profile
@mkirby
mkirby / scenarios.json
Created March 21, 2021 00:22
Data: How To Create A Semantic UI React Functional Table Component
[
{
"id": 1,
"coords": "G-18",
"name": "Black Barrow",
"unlocked": false,
"completed": false,
"unlocks_when_completed": [],
"locks_when_completed": []
},
@mkirby
mkirby / step_6_suir_functional_table_component.js
Last active March 20, 2021 23:10
Step 6: How To Create A Semantic UI React Functional Table Component
//let's add some styling touches and address spacing
//and lets hide the names of scenarios that are not unlocked yet
import React, {useState} from "react";
import scenarios from "./scenarios.json";
import { Table, Icon, Checkbox, Menu } from "semantic-ui-react";
function renderScenarioRows(scenarios, scenarioPage) {
// lets diplay 15 rows of data on each page
let startingIndex = scenarioPage * 15 - 15;
@mkirby
mkirby / step_5_suir_functional_table_component.js
Last active March 20, 2021 23:40
Step 5: How To Create A Semantic UI React Functional Table Component
//we have lots of rows of data - so why don't we paginate the table data!
//render the rows of data, including checkboxes which we need to import
//iterate over the array of scenarios
//for each scenario return 1 table row of data
//to change through the pages of data we need to..
//track the current page
//track the last page
//add a menu of two buttons, to change the page number
@mkirby
mkirby / step_4_suir_functional_table_component.js
Last active March 20, 2021 23:33
Step 4: How To Create A Semantic UI React Functional Table Component
//render the rows of data, including checkboxes
//iterate over the array of scenarios
//for each scenario return 1 table row of data
//import useState from react
import React, {useState} from "react";
import scenarios from "./scenarios.json";
import { Table, Icon, Checkbox } from "semantic-ui-react";
function renderScenarioRows(scenarios) {
@mkirby
mkirby / step_3_suir_functional_table_component.js
Last active March 20, 2021 22:40
Step 3: How To Create A Semantic UI React Functional Table Component
//create the table title and column names
//we're using both icons and text for column names!
//don't forget to import Icon from SUIR
import React from "react";
import scenarios from "./scenarios.json";
import { Table, Icon } from "semantic-ui-react";
function ScenarioTable() {
return (
@mkirby
mkirby / step_2_suir_functional_table_component.js
Last active March 20, 2021 22:40
Step 2: How To Create A Semantic UI React Functional Table Component
//build out the table structure
// 1. add the header
// 2. add the body
// 3. add the footer
import React from "react";
import scenarios from "./scenarios.json";
import { Table } from "semantic-ui-react";
function ScenarioTable() {
@mkirby
mkirby / step_1_suir_functional_table_component.js
Last active March 20, 2021 22:41
Step 1: How to create a Semantic UI React functional table component
//import, create, and export a base functional component setup
import React from "react";
import scenarios from "./scenarios.json";
import { Table } from "semantic-ui-react";
function ScenarioTable() {
return (
<div className="scenario__table">
<Table>