Skip to content

Commit

Permalink
feat: updated styles
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaPontrandolfo committed Nov 20, 2023
1 parent 916057f commit 1938c54
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 126 deletions.
58 changes: 58 additions & 0 deletions apps/docs-website/src/components/ConfigCombinationForm.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.checkboxGroupContainer {
display: flex;
align-items: center;
border: 2px solid var(--ifm-toc-border-color);
border-radius: var(--ifm-global-radius);
padding: 9px 16px 8px 16px;
}

.nativeCheckbox {
display: block;
margin-right: 12px;
}

.nativeCheckbox input {
padding: 0;
height: initial;
width: initial;
margin-bottom: 0;
display: none;
cursor: pointer;
}

.nativeCheckbox label {
position: relative;
cursor: pointer;
user-select: none;
}

.nativeCheckbox label:before {
content: "";
-webkit-appearance: none;
background-color: transparent;
border: 2px solid var(--ifm-toc-border-color);
border-radius: var(--ifm-global-radius);
box-shadow:
0 1px 2px rgba(0, 0, 0, 0.05),
inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05);
padding: 10px;
display: inline-block;
position: relative;
vertical-align: middle;
cursor: pointer;
margin-right: 5px;
top: -2px;
}

.nativeCheckbox input:checked + label:after {
content: "";
display: block;
position: absolute;
top: 3px;
left: 9px;
width: 4px;
height: 10px;
border: solid var(--ifm-color-primary);
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
4 changes: 3 additions & 1 deletion apps/docs-website/src/components/ConfigCombinationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useForm } from "react-hook-form";
import { DevTool } from "@hookform/devtools";
import styles from "./RulesTable.module.css";
import { configCombinationDefaultValues } from "./constants";
import styles from "./ConfigCombinationForm.module.css";

interface ConfigCombinationFormProps {
setTableData: (data: FormInputs) => void;
Expand All @@ -25,13 +25,15 @@ export const ConfigCombinationForm = ({

const handleVitestChange = (isChecked: boolean) => {
setValue("vitest", isChecked, { shouldDirty: true, shouldTouch: true });

if (isChecked) {
setValue("jest", false, { shouldDirty: true, shouldTouch: true });
}
};

const handleJestChange = (isChecked: boolean) => {
setValue("jest", isChecked, { shouldDirty: true, shouldTouch: true });

if (isChecked) {
setValue("vitest", false, { shouldDirty: true, shouldTouch: true });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.container {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 2rem;
}

.label {
color: var(--ifm-color-emphasis-600);
}

.number {
font-size: 18px;
font-weight: 500;
}
15 changes: 8 additions & 7 deletions apps/docs-website/src/components/QueriedRulesMetricsGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styles from "./RulesTable.module.css";
import styles from "./QueriedRulesMetricsGroup.module.css";

interface QueriedRulesMetricsGroupProps {
totalAvailableRulesAmount: number;
Expand All @@ -12,17 +12,18 @@ export const QueriedRulesMetricsGroup = ({
filteredRulesAmount,
}: QueriedRulesMetricsGroupProps): JSX.Element => {
return (
<div className={styles.queriedRulesMetricsGroup}>
<div className={styles.container}>
<div>
<span>Total available rules: </span>
<span>{totalAvailableRulesAmount}</span>
<span className={styles.label}>Total available rules: </span>
<span className={styles.number}>{totalAvailableRulesAmount}</span>
</div>
<div>
<span>Current config rules: </span>
<span>{fetchedConfigRulesAmount}</span>
<span className={styles.label}>Current config rules: </span>
<span className={styles.number}>{fetchedConfigRulesAmount}</span>
</div>
<div>
<span>Filtered rules</span>: <span>{filteredRulesAmount}</span>
<span className={styles.label}>Filtered rules: </span>
<span className={styles.number}>{filteredRulesAmount}</span>
</div>
</div>
);
Expand Down
66 changes: 0 additions & 66 deletions apps/docs-website/src/components/RulesTable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,69 +40,3 @@
margin-bottom: 16px;
gap: 1rem;
}

.checkboxGroupContainer {
display: flex;
align-items: center;
border: 2px solid var(--ifm-toc-border-color);
border-radius: var(--ifm-global-radius);
padding: 9px 16px 8px 16px;
}

.nativeCheckbox {
display: block;
margin-right: 12px;
}

.nativeCheckbox input {
padding: 0;
height: initial;
width: initial;
margin-bottom: 0;
display: none;
cursor: pointer;
}

.nativeCheckbox label {
position: relative;
cursor: pointer;
user-select: none;
}

.nativeCheckbox label:before {
content: "";
-webkit-appearance: none;
background-color: transparent;
border: 2px solid var(--ifm-toc-border-color);
border-radius: var(--ifm-global-radius);
box-shadow:
0 1px 2px rgba(0, 0, 0, 0.05),
inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05);
padding: 10px;
display: inline-block;
position: relative;
vertical-align: middle;
cursor: pointer;
margin-right: 5px;
top: -2px;
}

.nativeCheckbox input:checked + label:after {
content: "";
display: block;
position: absolute;
top: 3px;
left: 9px;
width: 4px;
height: 10px;
border: solid var(--ifm-color-primary);
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}

.queriedRulesMetricsGroup {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 2rem;
}
8 changes: 4 additions & 4 deletions apps/docs-website/src/components/RulesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export const RulesTable = (): JSX.Element => {
const [isLoading, setIsLoading] = useState(false);
const [pluginsNames, setPluginsNames] = useState<string[]>([]);
const [totalAvailableRulesAmount, setTotalAvailableRulesAmount] = useState(0);
const [fetchedConfigRulesAmount, setFetchedConfigRulesAmount] = useState(0);
const [configCombination, setConfigCombination] = useState<SheriffSettings>(
configCombinationDefaultValues,
);
Expand Down Expand Up @@ -98,8 +97,9 @@ export const RulesTable = (): JSX.Element => {

const fetchedData: ServerResponse = await response.json();

setTotalAvailableRulesAmount(fetchedData.totalAvailableRulesAmount);
setFetchedConfigRulesAmount(fetchedData.compiledConfig.length);
setTotalAvailableRulesAmount(
fetchedData.totalAvailableRulesAmount ?? 0,
);
setPluginsNames(fetchedData.pluginsNames);
setData(filterDuplicateRules(fetchedData.compiledConfig));
} catch (error) {
Expand Down Expand Up @@ -219,7 +219,7 @@ export const RulesTable = (): JSX.Element => {
</div>
<QueriedRulesMetricsGroup
totalAvailableRulesAmount={totalAvailableRulesAmount}
fetchedConfigRulesAmount={fetchedConfigRulesAmount}
fetchedConfigRulesAmount={data.length}
filteredRulesAmount={table.getRowModel().rows.length}
/>
</div>
Expand Down
43 changes: 0 additions & 43 deletions apps/docs-website/src/pages/Homepage.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions apps/docs-website/src/pages/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@
opacity: 1 !important;
margin-top: 2px;
}

.heroActionsBlock {
max-width: 24rem;
margin: 0 auto;
}
45 changes: 41 additions & 4 deletions apps/docs-website/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import Layout from "@theme/Layout";
import { clsx } from "clsx";
import Link from "@docusaurus/Link";
import CodeBlock from "@theme/CodeBlock";
import SheriffLogo from "../../static/img/sheriff-logo.svg";
import styles from "./index.module.css";
import { Homepage } from "./Homepage";

const App = (): JSX.Element => {
const Homepage = (): JSX.Element => {
const { siteConfig } = useDocusaurusContext();

return (
Expand All @@ -12,9 +15,43 @@ const App = (): JSX.Element => {
description={siteConfig.tagline}
wrapperClassName={styles.homepageWrapper}
>
<Homepage />
<header className={styles.heroBanner}>
<main className="container">
<div className="margin--md">
<SheriffLogo />
</div>
<h1 className="hero__title">{siteConfig.title}</h1>
<p className={"hero__subtitle margin-bottom--lg"}>
{siteConfig.tagline}
</p>
<div className={styles.heroActionsBlock}>
<div
className={clsx(
"margin-bottom--lg padding-top--md",
styles.buttons,
)}
>
<Link
className="button button--primary button--lg"
to="/docs/introduction"
>
Get Started
</Link>
<Link
className="button button--outline button--secondary button--lg"
to="/docs/rules"
>
Explore Rules
</Link>
</div>
<CodeBlock className={styles.codeblock} language="bash">
npx create-sheriff-config
</CodeBlock>
</div>
</main>
</header>
</Layout>
);
};

export default App;
export default Homepage;
2 changes: 1 addition & 1 deletion packages/sheriff-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ export interface SheriffSettings {
export interface ServerResponse {
compiledConfig: Entry[];
pluginsNames: string[];
totalAvailableRulesAmount: number;
totalAvailableRulesAmount?: number;
}

0 comments on commit 1938c54

Please sign in to comment.