1
0

fix: make the website look nice by adjusting css

This commit is contained in:
Rokas Puzonas 2022-02-07 23:33:25 +02:00
parent ad3627491e
commit 0903a24433
5 changed files with 32 additions and 40 deletions

View File

@ -1,14 +1,3 @@
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App {
padding: 3em;
background-color: #1E1E1E;
@ -17,19 +6,22 @@
display: flex;
flex-direction: column;
justify-content: center;
font-size: calc(10px + 1vmin);
font-size: 16px;
color: white;
}
.App-link {
color: #61dafb;
input, select, button {
background-color: #131313;
color: white;
border: 1px solid black;
margin: 0.25em 0.5em;
padding: 0.5em;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
button:hover {
background-color: #1F1F1F;
}
button:active {
background-color: black;
}

View File

@ -2,7 +2,7 @@ import { useState } from 'react';
import './App.css';
import TableDefinitionForm from './TableDefinitionForm';
import TableMethodCodeBlock from './TableMethodCodeBlock';
import { TableDefinition } from './TableMethodGenerator';
import { TableColumns } from './TableMethodGenerator';
function App() {
let [columns, setColumns] = useState<TableColumns>([
@ -38,7 +38,7 @@ function App() {
}
])
let [generatorOptions, setGeneratorOptions] = useState<TableMethodGeneratorOptions>({});
// let [generatorOptions, setGeneratorOptions] = useState<TableMethodGeneratorOptions>({});
const onChange = (e: TableColumns) => {
columns = e
@ -50,7 +50,7 @@ function App() {
<main>
<TableDefinitionForm value={columns} onChange={onChange} />
<hr />
<TableMethodCodeBlock columns={columns} options={generatorOptions}/>
<TableMethodCodeBlock columns={columns}/>
</main>
</div>
);

View File

@ -1,6 +1,5 @@
import { ChangeEvent, useState } from "react"
import { Alignment, TableColumn, TableColumns } from "./TableMethodGenerator"
import { Alignment, generate, TableColumn, TableColumns } from "./TableMethodGenerator"
interface TableColumnProps {
value: TableColumn
@ -80,15 +79,21 @@ function TableDefinitionForm(props: TableDefinitionProps) {
}
}
const onClickCopy = () => {
navigator.clipboard.writeText(generate(columns))
}
return (
<form onSubmit={(e) => e.preventDefault()}>
<label>Column:</label>
<label>Column name:</label>
<input
type="text"
value={currentName}
onChange={(e) => setCurrentName(e.target.value)}
onKeyPress={(e) => e.key === "Enter" && addRow()}
/>
<button onClick={onClickCopy}>Insert column</button>
<button onClick={onClickCopy}>Copy code 📋!</button>
<ol>
{columns.map((item, i) =>
<TableDefinitionRow key={i} value={item} onChange={(e) => updateRow(i, e)}/>

View File

@ -7,22 +7,17 @@ SyntaxHighlighter.registerLanguage('csharp', csharp);
interface Props {
columns: TableColumns
options: TableMethodGeneratorOptions
options?: TableMethodGeneratorOptions
}
function TableMethodCodeBlock(props: Props) {
let script = generate(props.columns, props.options)
const onClickCopy = () => {
navigator.clipboard.writeText(script)
}
return (
<div>
<SyntaxHighlighter language="csharp" style={vs2015}>
{script}
</SyntaxHighlighter>
<button onClick={onClickCopy}>Copy code!</button>
</div>
)
}

View File

@ -31,17 +31,17 @@ function get_total_width(columns: TableColumns): number {
return total_width;
}
export function generate(columns: TableColumns, options: TableMethodGeneratorOptions): string {
const method_name = options.method_name || "PrintTable"
export function generate(columns: TableColumns, options?: TableMethodGeneratorOptions): string {
const method_name = options?.method_name || "PrintTable"
if (columns.length === 0) {
return `static void ${method_name}()\n{\n}`;
}
const empty_message = options.empty_message || "Empty"
const container_name = options.container_name || "container"
const container_type = options.container_type || "Container"
const entry_name = options.entry_name || "e"
const entry_type = options.entry_type || "Entry"
const empty_message = options?.empty_message || "Empty"
const container_name = options?.container_name || "container"
const container_type = options?.container_type || "Container"
const entry_name = options?.entry_name || "e"
const entry_type = options?.entry_type || "Entry"
// Total width
const total_width = get_total_width(columns)