Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the position of searchbox, make the card containers responsive #287

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions src/components/Events/index.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import React from "react";
import { Link, navigate } from "gatsby";
import './style.css'

import eventsService from "../../services/events";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faTable, faTableList, faClose } from '@fortawesome/free-solid-svg-icons'
import LoadContent from "../../commons/LoadContent";
import participationStatus from "../../services/participationStatus";

import './style.css'




const styles = {
eventCard: {
marginRight: 20,
marginBottom: 20,
// marginRight: 20,
// marginBottom: 20,
padding: 20,
width: 285,
borderRadius: 3,
minHeight: 200,
height: "auto",
width: "100%",
borderRadius: 5,
border: "2px solid rgba(0, 0, 0, .1)",
color: "inherit",
boxShadow: "0px 5px 20px -4px rgba(0, 0, 0, .1)",
transition: "box-shadow .2s ease",
transition: "all .2s ease",
":hover": {
color: "inherit",
boxShadow: "0px 5px 50px -4px rgba(0, 0, 0, .1)",
transform: "translateY(-10px)"
},
},
table_styles: {
Expand All @@ -47,10 +48,9 @@ const EventCard = ({ event }) => (
}}>
{event.name}
</div>
<div css={{
fontSize: "0.9em",
color: new Date() > new Date(event.endDate) ? "red" : "green",
}}>
<div
className={`text-[0.9em] ${new Date() > new Date(event.endDate) ? "text-red-500" : "text-green-500"
}`}>
{
new Date() > new Date(event.endDate)
? "ended " + (new Date(event.endDate)).toLocaleString()
Expand Down Expand Up @@ -167,23 +167,27 @@ export default class Events extends React.Component {
<h2 className="mucapp ">Events</h2>
<Link to="/events/add"><button className="mucapp">Add Event</button></Link>
</div>
<div className="text-center">
<div className="text-center flex justify-start items-center py-5">
<FontAwesomeIcon icon={faTable} style={{ padding: 4, color: "grey" }} />
<input type="checkbox" className="toggle" data-theme="light" onClick={() => this.setState({ mode: this.state.mode === "table" ? "card" : "table" })} />
<FontAwesomeIcon icon={faTableList} style={{ padding: 4, color: "grey" }} />
</div>

<LoadContent loading={this.state.loading} noDiv={true}>
<div className="search-container">
<input
type="text"
placeholder="Search by event name"
value={this.state.searchQuery}
onChange={this.handleSearch}
title="Enter the event name to search"
/>
<div className="clear-icon-container" onClick={() => { this.setState({ searchQuery: "" }) }} title="Clear">
<FontAwesomeIcon icon={faClose} />
<div className="flex justify-start items-start">

<div className=" border border-1 border-slate-400 flex justify-center items-center rounded-full px-2 mb-5 w-full md:w-1/2 lg:w-1/3 xl:w-72">
<input
type="text"
placeholder="Search by event name"
value={this.state.searchQuery}
onChange={this.handleSearch}
title="Enter the event name to search"
className="h-full px-2 py-3 w-full rounded-full outline-none text-md"
/>
<div className="clear-icon-container" onClick={() => { this.setState({ searchQuery: "" }) }} title="Clear">
<FontAwesomeIcon icon={faClose} />
</div>
</div>
</div>
{this.state.mode === "table" ? <>
Expand Down Expand Up @@ -225,14 +229,17 @@ export default class Events extends React.Component {

</>
:
<div css={{
marginTop: 20,
display: "flex",
flexWrap: "wrap",
}}>
<div
// css={{
// marginTop: 20,
// display: "flex",
// flexWrap: "wrap",
// }}
className="h-auto w-full grid xl:grid-cols-5 md:grid-cols-2 gap-5"
>
{this.state.events
.filter((event) =>
event.name.toLowerCase().includes(this.state.searchQuery.toLowerCase())
event.name.toLowerCase().trim().includes(this.state.searchQuery.toLowerCase().trim())
)
.map((event, i) => (
<EventCard key={i} event={event} />
Expand Down
142 changes: 70 additions & 72 deletions src/components/Events/style.css
Original file line number Diff line number Diff line change
@@ -1,77 +1,75 @@
.table-data-row {
cursor: pointer;
color: black;
}

.event-list-outer-container{
width: 100%;
overflow-x: auto;
}

.table-data-row:hover {
background-color: black;
color: #ff5800;
cursor: pointer;
transition: 100ms color ease-in-out;
}

cursor: pointer;
color: black;
}

.event-list-outer-container {
width: 100%;
overflow-x: auto;
}

.table-data-row:hover {
background-color: black;
color: #ff5800;
cursor: pointer;
transition: 100ms color ease-in-out;
}

table {
max-width: 100%;
}

th {
min-width: 100px;
width: auto;
}

.search-container {
border: 1px solid black;
/* width: 300px; */
/* border-radius: 5px; */
/* display: flex; */
/* align-items: center; */
/* justify-content: center; */
}

.search-container input {
padding: 10px 10px;
width: 100%;
font-size: 16px;
border-radius: 5px;
outline: none;
font-weight: 500;
}

.clear-icon-container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 40px;
color: gray;
cursor: pointer;
}

.clear-icon-container:hover {
color: black;
}

table:first-child {
position: relative;
}

@media only screen and (max-width: 757px) {
table {
max-width: 100%;
}

th{
min-width: 100px;
width: auto;
}

.search-container {
border: 1px solid black;
width: 300px;
margin: 20px auto;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;

input {
padding: 10px 10px;
width: 100%;
font-size: 16px;
border-radius: 5px;
outline: none;
font-weight: 500;
}


}

.clear-icon-container{
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 40px;
color: gray;
cursor: pointer;
width: 100% !important;
}

.clear-icon-container:hover{
color: black;
th,
td {
width: 150px;
}
table:first-child{
position: relative;

th:first-child {
position: relative !important;
}

@media only screen and (max-width: 757px) {
table{
width: 100% !important;
}
th, td{
width: 150px;
}

th:first-child{
position: relative !important;
}
}
}
40 changes: 21 additions & 19 deletions src/components/Judges/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { faClose } from '@fortawesome/free-solid-svg-icons'

const styles = {
judgeCard: {
display: "inline-block",
marginRight: 20,
marginBottom: 20,
// display: "inline-block",
// marginRight: 20,
// marginBottom: 20,
padding: 20,
width: 250,
height: "auto",
width: "100%",
borderRadius: 3,
border: "2px solid rgba(0, 0, 0, .1)",
color: "inherit",
Expand Down Expand Up @@ -64,10 +65,7 @@ const Judge = (props) => {
};

const JudgesList = (props) => (
<div css={{
display: "flex",
flexWrap: "wrap",
}}>
<div className="h-auto w-full grid xl:grid-cols-5 md:grid-cols-2 gap-5">
<Link to="/judges/add" css={{
...styles.judgeCard,
backgroundColor: "#ff5800",
Expand Down Expand Up @@ -119,19 +117,23 @@ export default class Judges extends React.Component {
render = () => (
<div>
<h2 className="mucapp">Judges</h2>
<div className="search-container">
<input
type="text"
placeholder="Search by Judge name"
value={this.state.searchQuery}
onChange={this.handleSearch}
title="Enter the judge name to search"
/>
<div className="clear-icon-container" onClick={() => { this.setState({ searchQuery: "" }) }} title="Clear">
<FontAwesomeIcon icon={faClose} />
<div className="flex justify-start items-start">

<div className=" border border-1 border-slate-400 mt-2 flex justify-center items-center rounded-full px-2 mb-5 w-full md:w-1/2 lg:w-1/3 xl:w-72">
<input
type="text"
placeholder="Search by event name"
value={this.state.searchQuery}
onChange={this.handleSearch}
title="Enter the event name to search"
className="h-full px-2 py-3 w-full rounded-full outline-none text-md"
/>
<div className="clear-icon-container" onClick={() => { this.setState({ searchQuery: "" }) }} title="Clear">
<FontAwesomeIcon icon={faClose} />
</div>
</div>
</div>
<div>
<div className="">
{
this.state.loading
? <Loader />
Expand Down
Loading
Loading