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

Cleanup code. Name variables properly. #183

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use clsx properly
  • Loading branch information
smartclash committed Jul 14, 2021
commit 56ea2af6c02f7e4164003ed31561211509e673a4
20 changes: 10 additions & 10 deletions src/components/Cards/InfoCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ const InfoCard = ({ title, value, delta = null, small = false }) => {
<CardBody className="flex flex-col">
<div>
<p
className={clsx(
small ? "mb-1 text-xs" : "mb-2 text-sm",
"dark:text-gray-400 text-gray-600 font-medium"
)}
className={clsx("dark:text-gray-400 text-gray-600 font-medium", {
"mb-1 text-xs": small,
"mb-2 text-sm": !small,
})}
>
{title}
</p>
<div className="flex">
<animated.p
className={clsx(
small ? "text-base" : "text-lg",
"dark:text-gray-200 text-gray-700 font-semibold"
"dark:text-gray-200 text-gray-700 font-semibold",
{ "text-base": small, "text-lg": !small }
)}
>
{_value.interpolate((x) => Math.round(x))}
</animated.p>
{delta !== null && (
<animated.span
className={clsx(
small ? "text-xs" : "text-sm",
"ml-2 dark:text-gray-400 text-gray-600"
)}
className={clsx("ml-2 dark:text-gray-400 text-gray-600", {
"text-xs": small,
"text-sm": !small,
})}
>
{_delta.interpolate((y) => {
const x = Math.round(y);
Expand Down
10 changes: 7 additions & 3 deletions src/components/Cards/OxygenCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Card } from "@windmill/react-ui";
import React from "react";
import { OXYGEN_TYPES } from "../../utils/constants";
import clsx from "clsx";

const OxygenCard = ({ data }) => {
const getSVG = (parameter) => {
Expand Down Expand Up @@ -94,9 +95,12 @@ const OxygenCard = ({ data }) => {
>
<div className="flex flex-row justify-center">
<div
className={`text-gray-800 dark:text-gray-200 text-lg font-semibold ${
data.is_low[idx] ? "text-red-500 dark:text-red-500" : ""
}`}
className={clsx(
"dark:text-gray-200 text-gray-800 text-lg font-semibold",
{
"text-red-500 dark:text-red-500": data.is_low[idx],
}
)}
>
{val}
</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/DistrictDashboard/Capacity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Button, Input } from "@windmill/react-ui";
import Pagination from "../Pagination";
import clsx from "clsx";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import fuzzysort from "fuzzysort";
Expand Down
4 changes: 2 additions & 2 deletions src/components/DistrictDashboard/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const Filter = ({
return (
<div
className={clsx(
floating ? " mt-10 flex-shrink-0 " : "mb-8 rounded-lg",
"flex flex-col items-center justify-between px-1 py-1 dark:bg-gray-800 bg-white shadow-md sm:px-4 sm:py-2 md:flex-row"
"flex flex-col items-center justify-between px-1 py-1 dark:bg-gray-800 bg-white shadow-md sm:px-4 sm:py-2 md:flex-row",
{ "mt-10 flex-shrink-0": floating, "mb-8 rounded-lg": !floating }
)}
>
<p className="inline-flex dark:text-gray-400">Filters</p>
Expand Down
15 changes: 7 additions & 8 deletions src/components/DistrictDashboard/GMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import {
GMAP_KEY,
} from "../../utils/constants";
import Marker from "../Marker";
import clsx from "clsx";

const selectedButtonClasses = (bool) => {
const d = " px-4 py-2 font-bold rounded-lg shadow ";
return (
d +
(bool
? "bg-primary-500 text-white"
: "dark:hover:bg-primary-500 hover:text-white hover:bg-primary-500 bg-gray-50 dark:bg-gray-700 text-gray-800 dark:text-white")
);
const selectedButtonClasses = (isWhite) => {
return clsx("px-4 py-2 font-bold rounded-lg shadow", {
"bg-primary-500 text-white": isWhite,
"dark:hover:bg-primary-500 hover:text-white hover:bg-primary-500 bg-gray-50 dark:bg-gray-700 text-gray-800 dark:text-white":
!isWhite,
});
};

const GMap = ({ district, facilities, className }) => {
Expand Down