fix: make the website look nice by adjusting css
This commit is contained in:
parent
ad3627491e
commit
0903a24433
34
src/App.css
34
src/App.css
@ -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 {
|
.App {
|
||||||
padding: 3em;
|
padding: 3em;
|
||||||
background-color: #1E1E1E;
|
background-color: #1E1E1E;
|
||||||
@ -17,19 +6,22 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: calc(10px + 1vmin);
|
font-size: 16px;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.App-link {
|
input, select, button {
|
||||||
color: #61dafb;
|
background-color: #131313;
|
||||||
|
color: white;
|
||||||
|
border: 1px solid black;
|
||||||
|
margin: 0.25em 0.5em;
|
||||||
|
padding: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes App-logo-spin {
|
button:hover {
|
||||||
from {
|
background-color: #1F1F1F;
|
||||||
transform: rotate(0deg);
|
}
|
||||||
}
|
|
||||||
to {
|
button:active {
|
||||||
transform: rotate(360deg);
|
background-color: black;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { useState } from 'react';
|
|||||||
import './App.css';
|
import './App.css';
|
||||||
import TableDefinitionForm from './TableDefinitionForm';
|
import TableDefinitionForm from './TableDefinitionForm';
|
||||||
import TableMethodCodeBlock from './TableMethodCodeBlock';
|
import TableMethodCodeBlock from './TableMethodCodeBlock';
|
||||||
import { TableDefinition } from './TableMethodGenerator';
|
import { TableColumns } from './TableMethodGenerator';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
let [columns, setColumns] = useState<TableColumns>([
|
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) => {
|
const onChange = (e: TableColumns) => {
|
||||||
columns = e
|
columns = e
|
||||||
@ -50,7 +50,7 @@ function App() {
|
|||||||
<main>
|
<main>
|
||||||
<TableDefinitionForm value={columns} onChange={onChange} />
|
<TableDefinitionForm value={columns} onChange={onChange} />
|
||||||
<hr />
|
<hr />
|
||||||
<TableMethodCodeBlock columns={columns} options={generatorOptions}/>
|
<TableMethodCodeBlock columns={columns}/>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { ChangeEvent, useState } from "react"
|
import { ChangeEvent, useState } from "react"
|
||||||
import { Alignment, TableColumn, TableColumns } from "./TableMethodGenerator"
|
import { Alignment, generate, TableColumn, TableColumns } from "./TableMethodGenerator"
|
||||||
|
|
||||||
|
|
||||||
interface TableColumnProps {
|
interface TableColumnProps {
|
||||||
value: TableColumn
|
value: TableColumn
|
||||||
@ -80,15 +79,21 @@ function TableDefinitionForm(props: TableDefinitionProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onClickCopy = () => {
|
||||||
|
navigator.clipboard.writeText(generate(columns))
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(e) => e.preventDefault()}>
|
<form onSubmit={(e) => e.preventDefault()}>
|
||||||
<label>Column:</label>
|
<label>Column name:</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={currentName}
|
value={currentName}
|
||||||
onChange={(e) => setCurrentName(e.target.value)}
|
onChange={(e) => setCurrentName(e.target.value)}
|
||||||
onKeyPress={(e) => e.key === "Enter" && addRow()}
|
onKeyPress={(e) => e.key === "Enter" && addRow()}
|
||||||
/>
|
/>
|
||||||
|
<button onClick={onClickCopy}>Insert column</button>
|
||||||
|
<button onClick={onClickCopy}>Copy code 📋!</button>
|
||||||
<ol>
|
<ol>
|
||||||
{columns.map((item, i) =>
|
{columns.map((item, i) =>
|
||||||
<TableDefinitionRow key={i} value={item} onChange={(e) => updateRow(i, e)}/>
|
<TableDefinitionRow key={i} value={item} onChange={(e) => updateRow(i, e)}/>
|
||||||
|
@ -7,22 +7,17 @@ SyntaxHighlighter.registerLanguage('csharp', csharp);
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
columns: TableColumns
|
columns: TableColumns
|
||||||
options: TableMethodGeneratorOptions
|
options?: TableMethodGeneratorOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableMethodCodeBlock(props: Props) {
|
function TableMethodCodeBlock(props: Props) {
|
||||||
let script = generate(props.columns, props.options)
|
let script = generate(props.columns, props.options)
|
||||||
|
|
||||||
const onClickCopy = () => {
|
|
||||||
navigator.clipboard.writeText(script)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SyntaxHighlighter language="csharp" style={vs2015}>
|
<SyntaxHighlighter language="csharp" style={vs2015}>
|
||||||
{script}
|
{script}
|
||||||
</SyntaxHighlighter>
|
</SyntaxHighlighter>
|
||||||
<button onClick={onClickCopy}>Copy code!</button>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -31,17 +31,17 @@ function get_total_width(columns: TableColumns): number {
|
|||||||
return total_width;
|
return total_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generate(columns: TableColumns, options: TableMethodGeneratorOptions): string {
|
export function generate(columns: TableColumns, options?: TableMethodGeneratorOptions): string {
|
||||||
const method_name = options.method_name || "PrintTable"
|
const method_name = options?.method_name || "PrintTable"
|
||||||
if (columns.length === 0) {
|
if (columns.length === 0) {
|
||||||
return `static void ${method_name}()\n{\n}`;
|
return `static void ${method_name}()\n{\n}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const empty_message = options.empty_message || "Empty"
|
const empty_message = options?.empty_message || "Empty"
|
||||||
const container_name = options.container_name || "container"
|
const container_name = options?.container_name || "container"
|
||||||
const container_type = options.container_type || "Container"
|
const container_type = options?.container_type || "Container"
|
||||||
const entry_name = options.entry_name || "e"
|
const entry_name = options?.entry_name || "e"
|
||||||
const entry_type = options.entry_type || "Entry"
|
const entry_type = options?.entry_type || "Entry"
|
||||||
|
|
||||||
// Total width
|
// Total width
|
||||||
const total_width = get_total_width(columns)
|
const total_width = get_total_width(columns)
|
||||||
|
Loading…
Reference in New Issue
Block a user