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

UI v2 remove cx twmerge #1415

Merged
merged 2 commits into from
Jul 27, 2023
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
2 changes: 0 additions & 2 deletions deepfence_frontend/apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@suspensive/react": "^1.11.2",
"@suspensive/react-query": "^1.11.2",
"@tanstack/react-query": "^4.29.17",
"classnames": "^2.3.2",
"dayjs": "^1.11.8",
"echarts": "^5.4.2",
"lodash-es": "^4.17.21",
Expand All @@ -35,7 +34,6 @@
"react-router-dom": "^6.14.0",
"react-use": "^17.4.0",
"sonner": "^0.1.1",
"tailwind-merge": "^1.13.2",
"tailwind-preset": "workspace:*",
"ui-components": "workspace:*"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { useFetcher, useRouteLoaderData } from 'react-router-dom';
import { cn } from 'tailwind-preset';
import { Dropdown, DropdownItem } from 'ui-components';

import { DFLink } from '@/components/DFLink';
Expand All @@ -12,12 +12,12 @@ export function AppHeader() {
const { email } = useRouteLoaderData('root') as { email: string };
return (
<header
className={classNames(
className={cn(
'fixed z-10 top-0 bg-white dark:bg-bg-left-nav h-[56px] w-full border-b border-gray-200 dark:border-bg-top-header',
)}
>
<div className="h-full flex items-center">
<div className={classNames('mr-auto ml-3')}>
<div className="mr-auto ml-3">
<DFLink
to="/"
style={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cx from 'classnames';
import React from 'react';
import { cn } from 'tailwind-preset';

import { DFLink } from '@/components/DFLink';

Expand All @@ -15,7 +15,7 @@ export const LinkButton = ({
return (
<DFLink
to={to}
className={cx(
className={cn(
'flex items-center hover:no-underline focus:no-underline active:no-underline',
'text-gray-800 dark:text-gray-100 hover:text-blue-600 hover:dark:text-blue-500',
'visited:text-gray-800 dark:visited:text-gray-100',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import cx from 'classnames';
import { CircleSpinner, Tooltip } from 'ui-components';

import { ErrorStandardLineIcon } from '@/components/icons/common/ErrorStandardLine';
import { ErrorStandardSolidIcon } from '@/components/icons/common/ErrorStandardSolid';

export const ScanStatusInProgress = () => {
return (
<div className={cx('flex items-center justify-center gap-x-2')}>
<div className="flex items-center justify-center gap-x-2">
<CircleSpinner size="md" />
<span className="text-h3 font-medium dark:text-text-text-and-icon">
Scan is in progress, please wait...
Expand All @@ -17,7 +16,7 @@ export const ScanStatusInProgress = () => {

export const ScanStatusInError = ({ errorMessage }: { errorMessage: string }) => {
return (
<div className={cx('flex items-center justify-center gap-x-2')}>
<div className="flex items-center justify-center gap-x-2">
{errorMessage ? (
<Tooltip content={errorMessage}>
<div className="w-6 h-6 dark:text-status-error rounded-full">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classNames from 'classnames';
import { useLocation, useRouteError } from 'react-router-dom';

const SVG404 = () => {
Expand Down Expand Up @@ -435,7 +434,7 @@ export const FourZeroFourAuthenticated = () => {
}

return (
<main className={classNames('pt-[64px] h-screen')}>
<main className="pt-[64px] h-screen">
<PageNotFoundComponent />
</main>
);
Expand Down
13 changes: 5 additions & 8 deletions deepfence_frontend/apps/dashboard/src/components/error/500.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import { useMemo, useState } from 'react';
import { useLocation, useRouteError } from 'react-router-dom';
import { cn } from 'tailwind-preset';

import { AppHeader } from '@/components/AppHeader';
import { getSideNavigationState, SideNavigation } from '@/components/SideNavigation';
Expand Down Expand Up @@ -1367,13 +1367,10 @@ export const FiveZeroZero = () => {
onExpandedChange={(state) => setSideNavExpanded(state)}
/>
<main
className={classNames(
'pt-[56px] h-screen overflow-auto transition-[margin-left]',
{
'ml-[60px]': !sideNavExpanded,
'ml-[240px]': sideNavExpanded,
},
)}
className={cn('pt-[56px] h-screen overflow-auto transition-[margin-left]', {
'ml-[60px]': !sideNavExpanded,
'ml-[240px]': sideNavExpanded,
})}
>
<ErrorComponent />
</main>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import cx from 'classnames';
import { useFetcher } from 'react-router-dom';
import { Button, TextInput } from 'ui-components';

Expand Down Expand Up @@ -41,9 +40,7 @@ export const Login = () => {
<DFLink
unstyled
to="/auth/forgot-password"
className={cx(
'ml-auto text-p5 underline text-blue-600 dark:text-accent-accent',
)}
className="ml-auto text-p5 underline text-blue-600 dark:text-accent-accent"
>
Forgot password?
</DFLink>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import { useState } from 'react';
import { Outlet } from 'react-router-dom';
import { cn } from 'tailwind-preset';

import { AppHeader } from '@/components/AppHeader';
import { getSideNavigationState, SideNavigation } from '@/components/SideNavigation';
Expand All @@ -17,13 +17,10 @@ export const RootLayout = () => {
onExpandedChange={(state) => setSideNavExpanded(state)}
/>
<main
className={classNames(
'pt-[56px] h-screen overflow-auto transition-[margin-left]',
{
'ml-[60px]': !sideNavExpanded,
'ml-[240px]': sideNavExpanded,
},
)}
className={cn('pt-[56px] h-screen overflow-auto transition-[margin-left]', {
'ml-[60px]': !sideNavExpanded,
'ml-[240px]': sideNavExpanded,
})}
>
<Outlet />
</main>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useSuspenseQuery } from '@suspensive/react-query';
import { useIsFetching } from '@tanstack/react-query';
import cx from 'classnames';
import { capitalize } from 'lodash-es';
import React, { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
import {
Expand All @@ -9,6 +8,7 @@ import {
useFetcher,
useSearchParams,
} from 'react-router-dom';
import { cn } from 'tailwind-preset';
import {
Badge,
Breadcrumb,
Expand Down Expand Up @@ -273,15 +273,9 @@ const ActionDropdown = ({
e.preventDefault();
onDownloadAction();
}}
disabled={!isScanComplete(scanStatus)}
>
<span
className={cx('flex items-center gap-x-2', {
'opacity-60 dark:opacity-30 cursor-default':
!isScanComplete(scanStatus),
})}
>
Download report
</span>
<span>Download report</span>
</DropdownItem>
<DropdownItem
onClick={(e) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import cx from 'classnames';
import { useLocation } from 'react-router-dom';
import { twMerge } from 'tailwind-merge';
import { cn } from 'tailwind-preset';
import { Breadcrumb, BreadcrumbLink } from 'ui-components';

type ConnectorHeaderProps = {
Expand Down Expand Up @@ -40,17 +39,15 @@ export const ConnectorHeader = ({
<Breadcrumb>
<BreadcrumbLink isLink>
<span
className={twMerge(
cx(
'w-6 h-6 rounded-full dark:bg-df-gray-200 text-p7 flex items-center justify-center',
'dark:bg-gray-700 dark:text-df-gray-100 cursor-default',
),
className={cn(
'w-6 h-6 rounded-full dark:bg-df-gray-200 text-p7 flex items-center justify-center',
'dark:bg-gray-700 dark:text-df-gray-100 cursor-default',
)}
>
1
</span>
<span
className={cx('flex items-center ml-2 cursor-default', {
className={cn('flex items-center ml-2 cursor-default', {
['dark:text-text-text-and-icon']: !isAddConnectorRoutePath(),
})}
>
Expand All @@ -59,18 +56,16 @@ export const ConnectorHeader = ({
</BreadcrumbLink>
<BreadcrumbLink className="cursor-auto">
<span
className={twMerge(
cx(
'w-6 h-6 rounded-full dark:bg-df-gray-200 text-p7 flex items-center justify-center',
'dark:bg-gray-700 dark:text-df-gray-100 cursor-default',
),
className={cn(
'w-6 h-6 rounded-full dark:bg-df-gray-200 text-p7 flex items-center justify-center',
'dark:bg-gray-700 dark:text-df-gray-100 cursor-default',
)}
>
2
</span>

<span
className={cx('cursor-auto ml-2', {
className={cn('cursor-auto ml-2', {
['dark:text-text-link']: isScanRoutePath(),
})}
>
Expand All @@ -79,17 +74,15 @@ export const ConnectorHeader = ({
</BreadcrumbLink>
<BreadcrumbLink>
<span
className={twMerge(
cx(
'w-6 h-6 rounded-full dark:bg-df-gray-200 text-p7 flex items-center justify-center',
'dark:bg-gray-700 dark:text-df-gray-100 cursor-default',
),
className={cn(
'w-6 h-6 rounded-full dark:bg-df-gray-200 text-p7 flex items-center justify-center',
'dark:bg-gray-700 dark:text-df-gray-100 cursor-default',
)}
>
3
</span>
<span
className={cx('cursor-auto ml-2', {
className={cn('cursor-auto ml-2', {
['dark:text-text-link']: isViewScanSummaryRoutePath(),
})}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import cx from 'classnames';
import { useRef } from 'react';
import { useState } from 'react';
import { useMemo } from 'react';
import { generatePath } from 'react-router-dom';
import { cn } from 'tailwind-preset';
import { Button, Card, Tabs } from 'ui-components';

import { ACCOUNT_CONNECTOR } from '@/components/hosts-connector/NoConnectors';
Expand Down Expand Up @@ -42,7 +42,7 @@ const CardConnect = ({ label, path, icon }: CardConnectProps) => {
return (
<div className="px-6">
<button
className={cx(
className={cn(
'text-sm text-left flex items-center w-full gap-5',
'border-b dark:border-bg-grid-border border-gray-200 h-[72px] dark:hover:text-text-input-value dark:bg-transparent',
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cx from 'classnames';
import { startCase } from 'lodash-es';
import { generatePath, useParams } from 'react-router-dom';
import { cn } from 'tailwind-preset';
import { Card } from 'ui-components';

import { AWSCloudFormation } from '@/components/clouds-connector/AWSCloudFormation';
Expand Down Expand Up @@ -52,7 +52,7 @@ const CardConnect = ({ label, path, icon }: CardConnectProps) => {
return (
<div className="px-6">
<button
className={cx(
className={cn(
'text-sm text-left flex items-center w-full gap-5',
'border-b dark:border-gray-700 border-gray-200 h-[72px] dark:text-gray-300 dark:bg-transparent',
)}
Expand Down Expand Up @@ -103,16 +103,10 @@ const Cloud = () => {
Connect an AWS, GCP, or Azure cloud account to check for compliance
misconfigurations.
</p>
<div className="flex flex-col">
<div className="flex flex-col dark:text-text-text-and-icon">
{connectors.map((connector) => {
return (
<div
key={connector.label}
className={cx(
'hover:bg-[linear-gradient(270deg,_#EBF5FF_-0.07%,_#FFFFFF_100%)]',
'dark:hover:bg-[linear-gradient(270deg,_#1c2431_-0.07%,_#1f2937_100%)]',
)}
>
<div key={connector.label} className="dark:hover:bg-bg-hover-2">
<CardConnect {...connector} />
</div>
);
Expand Down Expand Up @@ -158,16 +152,10 @@ const Host = () => {
Connect a K8s cluster, Docker container, or Linux host to check for
vulnerabilities, secrets, malware, and compliance misconfigurations.
</p>
<div className="flex flex-col">
<div className="flex flex-col dark:text-text-text-and-icon">
{connectors.map((connector) => {
return (
<div
key={connector.label}
className={cx(
'hover:bg-[linear-gradient(270deg,_#EBF5FF_-0.07%,_#FFFFFF_100%)]',
'dark:hover:bg-[linear-gradient(270deg,_#1c2431_-0.07%,_#1f2937_100%)]',
)}
>
<div key={connector.label} className="dark:hover:bg-bg-hover-2">
<CardConnect {...connector} />
</div>
);
Expand Down
2 changes: 0 additions & 2 deletions deepfence_frontend/packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@tanstack/react-table": "^8.9.3",
"classnames": "^2.3.2",
"cva": "npm:class-variance-authority@^0.6.0",
"lodash-es": "^4.17.21",
"react-use": "^17.4.0",
"tailwind-merge": "^1.13.2",
"tailwind-preset": "workspace:*"
},
"peerDependencies": {
Expand Down
Loading