edit selectors and styling
This commit is contained in:
parent
93085ab2c7
commit
2b533febc4
|
@ -1,9 +1,10 @@
|
||||||
import plus from '../assets/plus.svg'
|
import plus from '../assets/plus.svg'
|
||||||
import pencil from '../assets/pencil.svg'
|
import pencil from '../assets/pencil.svg'
|
||||||
import trash from '../assets/trash.svg'
|
import trash from '../assets/trash.svg'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link, Form, useNavigate } from 'react-router-dom'
|
||||||
export default function (props){
|
export default function (props) {
|
||||||
return(
|
const navigate = useNavigate()
|
||||||
|
return (
|
||||||
<header id="page-header">
|
<header id="page-header">
|
||||||
<h2>
|
<h2>
|
||||||
{props.super}
|
{props.super}
|
||||||
|
@ -12,17 +13,36 @@ export default function (props){
|
||||||
{props.heading}
|
{props.heading}
|
||||||
</h1>
|
</h1>
|
||||||
<span id="icon-container">
|
<span id="icon-container">
|
||||||
<Link to={`${props.url}/create`} >
|
|
||||||
<img src={plus}/>
|
<button onClick={() => { navigate(`${props.url}/create`) }}>
|
||||||
</Link>
|
<img src={plus} />
|
||||||
<Link to={`${props.url}${props?.id?`/${props.id}`:""}/edit`} >
|
</button>
|
||||||
<img src={pencil}/>
|
<button onClick={() => { navigate(`${props.url}${props?.id ? `/${props.id}` : ""}/edit`) }}>
|
||||||
</Link>
|
<img src={pencil} />
|
||||||
<Link to={`${props.url}${props?.id?`/${props.id}`:""}/delete`} >
|
</button>
|
||||||
<img src={trash}/>
|
<Form
|
||||||
</Link>
|
method="post"
|
||||||
|
action="delete"
|
||||||
|
onSubmit={(event) => {
|
||||||
|
if (
|
||||||
|
!confirm(
|
||||||
|
"Please confirm you want to delete this record."
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<button type="submit"
|
||||||
|
><img src={trash} /></button>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
}
|
}
|
23
src/main.jsx
23
src/main.jsx
|
@ -16,6 +16,9 @@ import { action as deleteStoryAction } from './routes/deleteStory';
|
||||||
import { action as deletePublicationAction } from './routes/deletePublication';
|
import { action as deletePublicationAction } from './routes/deletePublication';
|
||||||
import EditSubmission, {action as editSubmissionAction} from './routes/editSubmission';
|
import EditSubmission, {action as editSubmissionAction} from './routes/editSubmission';
|
||||||
import CreateSubmission, {action as createSubmissionAction} from './routes/createSubmission';
|
import CreateSubmission, {action as createSubmissionAction} from './routes/createSubmission';
|
||||||
|
import EditStoryRoot from './routes/editStoryRoot';
|
||||||
|
import EditPublicationRoot from './routes/editPublicationRoot';
|
||||||
|
import EditSubmissionRoot from './routes/editSubmissionRoot';
|
||||||
import './styles/index.css'
|
import './styles/index.css'
|
||||||
import {
|
import {
|
||||||
createBrowserRouter,
|
createBrowserRouter,
|
||||||
|
@ -28,6 +31,11 @@ const router = createBrowserRouter([
|
||||||
element: <Root/>,
|
element: <Root/>,
|
||||||
errorElement: <ErrorPage />,
|
errorElement: <ErrorPage />,
|
||||||
children:[
|
children:[
|
||||||
|
{
|
||||||
|
index:true,
|
||||||
|
element:<Submissions/>,
|
||||||
|
loader:submissionsLoader
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/stories",
|
path: "/stories",
|
||||||
element: <Stories/>,
|
element: <Stories/>,
|
||||||
|
@ -61,18 +69,33 @@ const router = createBrowserRouter([
|
||||||
loader: storiesLoader,
|
loader: storiesLoader,
|
||||||
action: editStoryAction
|
action: editStoryAction
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path:"/story/edit",
|
||||||
|
element: <EditStoryRoot/>,
|
||||||
|
loader: storiesLoader
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path:"/publication/:publicationId/edit",
|
path:"/publication/:publicationId/edit",
|
||||||
element: <EditPublication/>,
|
element: <EditPublication/>,
|
||||||
loader: publicationsLoader,
|
loader: publicationsLoader,
|
||||||
action: editPublicationAction
|
action: editPublicationAction
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path:"/publication/edit",
|
||||||
|
element: <EditPublicationRoot/>,
|
||||||
|
loader: publicationsLoader
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path:"/submission/:submissionId/edit",
|
path:"/submission/:submissionId/edit",
|
||||||
element: <EditSubmission/>,
|
element: <EditSubmission/>,
|
||||||
loader: editSubmissionLoader,
|
loader: editSubmissionLoader,
|
||||||
action: editSubmissionAction
|
action: editSubmissionAction
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path:"/submission/edit",
|
||||||
|
element: <EditSubmissionRoot/>,
|
||||||
|
loader: submissionsLoader
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path:"/story/create",
|
path:"/story/create",
|
||||||
element: <CreateStory/>,
|
element: <CreateStory/>,
|
||||||
|
|
|
@ -20,6 +20,7 @@ export default function CreatePublication(){
|
||||||
<div id="page-container">
|
<div id="page-container">
|
||||||
<PageHeader super={`Publication`} heading="CREATE"/>
|
<PageHeader super={`Publication`} heading="CREATE"/>
|
||||||
<Form method="post" id="new-story-form">
|
<Form method="post" id="new-story-form">
|
||||||
|
<label>Title:
|
||||||
<input
|
<input
|
||||||
placeholder='title'
|
placeholder='title'
|
||||||
aria-label="Title"
|
aria-label="Title"
|
||||||
|
@ -27,6 +28,8 @@ export default function CreatePublication(){
|
||||||
name="title"
|
name="title"
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
|
<label>Website:
|
||||||
<input
|
<input
|
||||||
placeholder='website'
|
placeholder='website'
|
||||||
aria-label="Website:"
|
aria-label="Website:"
|
||||||
|
@ -35,6 +38,8 @@ export default function CreatePublication(){
|
||||||
name="link"
|
name="link"
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
|
<label>Query after (days):
|
||||||
<input
|
<input
|
||||||
placeholder='1000'
|
placeholder='1000'
|
||||||
aria-label="Query after:"
|
aria-label="Query after:"
|
||||||
|
@ -43,6 +48,11 @@ export default function CreatePublication(){
|
||||||
name="query_after_days"
|
name="query_after_days"
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<button type="submit">SAVE</button>
|
<button type="submit">SAVE</button>
|
||||||
<button type="button">CANCEL</button>
|
<button type="button">CANCEL</button>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { Form, Link, useLoaderData } from "react-router-dom";
|
||||||
|
import Dropdown from "../Components/Dropdown";
|
||||||
|
import { useState } from "react";
|
||||||
|
export default function EditPublicationRoot (){
|
||||||
|
const {publications} = useLoaderData()
|
||||||
|
const publicationsOptions = publications?.map(row=>[row.id,row.title])
|
||||||
|
const [id,setId]=useState(1)
|
||||||
|
const handleChange = (event) => {
|
||||||
|
const value = event.target.value
|
||||||
|
console.log(value)
|
||||||
|
setId(value)
|
||||||
|
}
|
||||||
|
return(
|
||||||
|
<>
|
||||||
|
<div id="page-container">
|
||||||
|
<Form >
|
||||||
|
<h2>Which publication would you like to edit?</h2>
|
||||||
|
|
||||||
|
<Dropdown name="pub_id" value={id} options={publicationsOptions} handleChange={handleChange}/>
|
||||||
|
<br/>
|
||||||
|
<Link to={`/publication/${id}/edit`}>OK</Link>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { Form, Link, useLoaderData } from "react-router-dom";
|
||||||
|
import Dropdown from "../Components/Dropdown";
|
||||||
|
import { useState } from "react";
|
||||||
|
export default function EditStoryRoot (){
|
||||||
|
const {stories} = useLoaderData()
|
||||||
|
const storiesOptions = stories?.map(row=>[row.id,row.title])
|
||||||
|
const [id,setId]=useState(1)
|
||||||
|
const handleChange = (event) => {
|
||||||
|
const value = event.target.value
|
||||||
|
console.log(value)
|
||||||
|
setId(value)
|
||||||
|
}
|
||||||
|
return(
|
||||||
|
<>
|
||||||
|
<div id="page-container">
|
||||||
|
<Form >
|
||||||
|
<h2>Which story would you like to edit?</h2>
|
||||||
|
|
||||||
|
<Dropdown name="story_id" value={id} options={storiesOptions} handleChange={handleChange}/>
|
||||||
|
<br/>
|
||||||
|
<Link to={`/story/${id}/edit`}>OK</Link>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { Form, Link, useLoaderData } from "react-router-dom";
|
||||||
|
import Dropdown from "../Components/Dropdown";
|
||||||
|
import { useState } from "react";
|
||||||
|
export default function EditSubmissionRoot (){
|
||||||
|
const {submissions} = useLoaderData()
|
||||||
|
const submissionsOptions = submissions?.map(row=>[row.id,row.date_submitted])
|
||||||
|
const [id,setId]=useState(1)
|
||||||
|
const handleChange = (event) => {
|
||||||
|
const value = event.target.value
|
||||||
|
console.log(value)
|
||||||
|
setId(value)
|
||||||
|
}
|
||||||
|
return(
|
||||||
|
<>
|
||||||
|
<div id="page-container">
|
||||||
|
<Form >
|
||||||
|
<h2>Which submission would you like to edit?</h2>
|
||||||
|
<label>Date submitted:
|
||||||
|
<Dropdown name="sub_id" value={id} options={submissionsOptions} handleChange={handleChange}/>
|
||||||
|
|
||||||
|
</label>
|
||||||
|
<br/>
|
||||||
|
<Link to={`/submission/${id}/edit`}>OK</Link>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
|
@ -22,22 +22,7 @@ export default function Publication() {
|
||||||
sortByDefault='date_submitted'
|
sortByDefault='date_submitted'
|
||||||
header='Submissions:'
|
header='Submissions:'
|
||||||
></Table>
|
></Table>
|
||||||
<Link to={`/publication/${publicationData.id}/edit`}>EDIT</Link>
|
|
||||||
<Form
|
|
||||||
method="post"
|
|
||||||
action="delete"
|
|
||||||
onSubmit={(event) => {
|
|
||||||
if (
|
|
||||||
!confirm(
|
|
||||||
"Please confirm you want to delete this record."
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button type="submit">Delete</button>
|
|
||||||
</Form>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,6 +11,7 @@ export function Root() {
|
||||||
<div id="container">
|
<div id="container">
|
||||||
{navigation==="loading"?<Loader/>:""}
|
{navigation==="loading"?<Loader/>:""}
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
|
<h1>Submission <br/> Manager</h1> version 1.0
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<Link to={`stories`}>STORIES</Link>
|
<Link to={`stories`}>STORIES</Link>
|
||||||
|
|
|
@ -24,24 +24,8 @@ export default function Story() {
|
||||||
header='Submissions:'
|
header='Submissions:'
|
||||||
></Table>
|
></Table>
|
||||||
|
|
||||||
<Form
|
|
||||||
method="post"
|
|
||||||
action="delete"
|
|
||||||
onSubmit={(event) => {
|
|
||||||
if (
|
|
||||||
!confirm(
|
|
||||||
"Please confirm you want to delete this record."
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button type="submit">Delete</button>
|
|
||||||
</Form>
|
|
||||||
<Form>
|
|
||||||
<Link to={`/story/${storyData.id}/edit`}>EDIT</Link>
|
|
||||||
</Form>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,6 +8,7 @@ form{
|
||||||
padding:2rem;
|
padding:2rem;
|
||||||
width:max-content;
|
width:max-content;
|
||||||
margin:auto;
|
margin:auto;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +45,8 @@ input,select {
|
||||||
background-color: var(--fg-color);
|
background-color: var(--fg-color);
|
||||||
box-shadow: var(--box-shadow-light);
|
box-shadow: var(--box-shadow-light);
|
||||||
}
|
}
|
||||||
form button, form a{
|
form button, form a, #page-header button{
|
||||||
float:right;
|
display:inline;
|
||||||
font-size: 3.2rem;
|
font-size: 3.2rem;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border-radius: 2rem;
|
border-radius: 2rem;
|
||||||
|
@ -53,8 +54,9 @@ form button, form a{
|
||||||
margin:1rem;
|
margin:1rem;
|
||||||
margin-top: 4rem;
|
margin-top: 4rem;
|
||||||
background-color: hsl(var(--color-3),var(--light));
|
background-color: hsl(var(--color-3),var(--light));
|
||||||
|
|
||||||
}
|
}
|
||||||
form button:hover{
|
form button:hover, form a:hover, #page-header button:hover{
|
||||||
background-color: hsl(var(--color-3),var(--lightest));
|
background-color: hsl(var(--color-3),var(--lightest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,34 @@
|
||||||
#page-header img{
|
#page-header img {
|
||||||
width:5rem;
|
width: 5rem;
|
||||||
height: 5rem;
|
height: 5rem;
|
||||||
margin:1rem;
|
margin: 1rem;
|
||||||
filter: invert(83%) sepia(12%) saturate(387%) hue-rotate(129deg) brightness(89%) contrast(89%);}
|
filter: invert(83%) sepia(12%) saturate(387%) hue-rotate(129deg) brightness(89%) contrast(89%);
|
||||||
#page-header h1{
|
}
|
||||||
|
|
||||||
|
#page-header h1 {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
#page-header{
|
#page-header form {
|
||||||
display:flex;
|
padding: 0;
|
||||||
width:100%;
|
background-color: transparent;
|
||||||
justify-content:space-between;
|
box-shadow: none;
|
||||||
|
display:inline;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#icon-container{
|
#page-header {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#icon-container a{
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
#page-header h1{
|
||||||
|
font-size:6rem;
|
||||||
|
text-shadow: var(--text-shadow-light);
|
||||||
|
margin-right: 5rem;
|
||||||
}
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
#sidebar{
|
||||||
|
padding: 3rem;
|
||||||
|
background-image: linear-gradient(to right,hsl(var(--color-3),var(--medium))85%,hsla(var(--color-2),var(--light),0%));
|
||||||
|
color: white;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
#sidebar a{
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
#sidebar h1{
|
||||||
|
text-shadow: var(--text-shadow-dark);
|
||||||
|
font-size:4.5rem;
|
||||||
|
}
|
||||||
|
#sidebar a:hover{
|
||||||
|
text-shadow:
|
||||||
|
0 0 1em hsla(var(--accent),var(--off-white),50%);
|
||||||
|
}
|
|
@ -9,11 +9,14 @@
|
||||||
--off-white:98%;
|
--off-white:98%;
|
||||||
--lightest:90%;
|
--lightest:90%;
|
||||||
--light:85%;
|
--light:85%;
|
||||||
|
--medium:60%;
|
||||||
--dark:50%;
|
--dark:50%;
|
||||||
--darkest:20%;
|
--darkest:20%;
|
||||||
|
|
||||||
--box-shadow:10px 10px 30px 0px hsla(var(--color-5),var(--dark));
|
--box-shadow:10px 10px 30px 0px hsla(var(--color-5),var(--dark));
|
||||||
--box-shadow-light:5px 5px 30px 0px hsla(var(--color-5),var(--light));
|
--box-shadow-light:5px 5px 30px 0px hsla(var(--color-5),var(--light));
|
||||||
|
--text-shadow-light: 5px 5px 4px hsla(var(--color-5),var(--light));
|
||||||
|
--text-shadow-dark: 3px 3px 15px hsla(var(--color-5),var(--dark),70%);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
@import 'Variables.css';
|
@import 'Variables.css';
|
||||||
@import 'Form.css';
|
@import 'Form.css';
|
||||||
@import 'PageHeader.css';
|
@import 'PageHeader.css';
|
||||||
|
@import 'Sidebar.css';
|
||||||
*,
|
*,
|
||||||
*::before,
|
*::before,
|
||||||
*::after {
|
*::after {
|
||||||
|
@ -24,6 +25,20 @@ article ol,
|
||||||
article ul {
|
article ul {
|
||||||
list-style-position: inside;
|
list-style-position: inside;
|
||||||
}
|
}
|
||||||
|
a{
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:visited,a:link{
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
a:hover{
|
||||||
|
text-shadow:
|
||||||
|
1px 1px 2px white,
|
||||||
|
0 0 3em white,
|
||||||
|
0 0 1em hsl(var(--accent),var(--off-white));
|
||||||
|
}
|
||||||
html {
|
html {
|
||||||
font-size: 62.5%;
|
font-size: 62.5%;
|
||||||
-webkit-text-size-adjust: none;
|
-webkit-text-size-adjust: none;
|
||||||
|
@ -45,7 +60,7 @@ html {
|
||||||
|
|
||||||
#container{
|
#container{
|
||||||
display:grid;
|
display:grid;
|
||||||
grid-template-columns: 20rem 1fr ;
|
grid-template-columns: 35rem 1fr ;
|
||||||
}
|
}
|
||||||
#sidebar{
|
#sidebar{
|
||||||
font-size: 3.2rem;
|
font-size: 3.2rem;
|
||||||
|
|
Loading…
Reference in New Issue