Skip to content

Commit

Permalink
(refactor) Use classnames library to apply multiple classes
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen committed Nov 14, 2023
1 parent 38d3abc commit 5fa4e9b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
},
"packageManager": "[email protected]",
"dependencies": {
"classnames": "^2.3.2",
"dotenv": "^16.3.1"
}
}
19 changes: 12 additions & 7 deletions src/cohort-builder.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";

import classNames from "classnames";
import { Tab, Tabs, TabList, TabPanels, TabPanel } from "@carbon/react";
import { showToast, useLayoutType } from "@openmrs/esm-framework";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -169,12 +169,16 @@ const CohortBuilder: React.FC = () => {

return (
<div
className={`omrs-main-content ${styles.mainContainer} ${styles.cohortBuilder}`}
className={classNames(
"omrs-main-content",
styles.mainContainer,
styles.cohortBuilder
)}
>
<div
className={
className={classNames(
isLayoutTablet ? styles.tabletContainer : styles.desktopContainer
}
)}
>
<p className={styles.title}>{t("cohortBuilder", "Cohort Builder")}</p>
<div className={styles.tabContainer}>
Expand All @@ -183,9 +187,10 @@ const CohortBuilder: React.FC = () => {
</p>
<div className={styles.tab}>
<Tabs
className={`${styles.verticalTabs} ${
isLayoutTablet ? styles.tabletTab : styles.desktopTab
}`}
className={classNames(styles.verticalTabs, {
[styles.tabletTab]: isLayoutTablet,
[styles.desktopTab]: !isLayoutTablet,
})}
>
<TabList aria-label="navigation">
{tabs.map((tab: TabItem, index: number) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";

import classNames from "classnames";
import {
DatePicker,
DatePickerInput,
Expand Down Expand Up @@ -84,7 +84,7 @@ const SearchByDemographics: React.FC<SearchByProps> = ({ onSubmit }) => {
return (
<>
<Column>
<p className={`${styles.text} ${styles.genderTitle}`}>
<p className={classNames(styles.text, styles.genderTitle)}>
{t("gender", "Gender")}
</p>
<div className={styles.genderContainer}>
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,7 @@ __metadata:
"@types/webpack-env": ^1.18.0
"@typescript-eslint/eslint-plugin": ^5.51.0
"@typescript-eslint/parser": ^5.51.0
classnames: ^2.3.2
concurrently: ^7.6.0
css-loader: ^6.7.3
dayjs: ^1.11.7
Expand Down Expand Up @@ -6217,7 +6218,7 @@ __metadata:
languageName: node
linkType: hard

"classnames@npm:2.3.2":
"classnames@npm:2.3.2, classnames@npm:^2.3.2":
version: 2.3.2
resolution: "classnames@npm:2.3.2"
checksum: 2c62199789618d95545c872787137262e741f9db13328e216b093eea91c85ef2bfb152c1f9e63027204e2559a006a92eb74147d46c800a9f96297ae1d9f96f4e
Expand Down

0 comments on commit 5fa4e9b

Please sign in to comment.