Skip to content

Commit 88636cd

Browse files
authored
chore: update tabs & accordions ui (#961)
[![PR App][icn]][demo] | Fix RM-10694 :-------------------:|:----------: ## 🧰 Changes - Add `icon` and `iconColor` props to <Tab> - Replace default marker with icon in <Accordion> <img width="500" alt="image" src="https://github.com/user-attachments/assets/c4cd8fb6-776d-4e74-91fd-dd39f590256e"> ## 🧬 QA & Testing - [Broken on production][prod]. - [Working in this PR app][demo]. [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg
1 parent 350ff5a commit 88636cd

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

components/Accordion/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import React, { useState } from 'react';
33
import './style.scss';
44

55
const Accordion = ({ children, icon, iconColor, title }) => {
6+
const [isOpen, setIsOpen] = useState(false);
7+
68
return (
7-
<details className="Accordion">
9+
<details className="Accordion" onToggle={() => setIsOpen(!isOpen)}>
810
<summary className="Accordion-title">
11+
<i className={`Accordion-toggleIcon${isOpen ? '_opened' : ''} fa fa-chevron-right`}></i>
912
{icon && <i className={`Accordion-icon fa ${icon}`} style={{ color: `${iconColor}` }}></i>}
1013
{title}
1114
</summary>

components/Accordion/style.scss

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,31 @@
2626
border-bottom-left-radius: 0;
2727
border-bottom-right-radius: 0;
2828
}
29+
30+
&::marker {
31+
content: "";
32+
}
33+
34+
&::-webkit-details-marker {
35+
display: none;
36+
}
37+
}
38+
39+
&-toggleIcon,
40+
&-toggleIcon_opened {
41+
color: var(--color-text-default, #384248);
42+
font-size: 14px;
43+
margin-left: 5px;
44+
margin-right: 10px;
45+
transition: transform 0.1s;
46+
47+
&_opened {
48+
transform: rotate(90deg);
49+
}
2950
}
3051

3152
&-icon {
3253
color: var(--project-color-primary, inherit);
33-
margin-left: 10px;
3454
margin-right: 10px;
3555
}
3656

components/Tabs/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Tabs = ({ children }) => {
1919
<nav className="TabGroup-nav">
2020
{children?.map((tab, index: number) =>
2121
<button className={`TabGroup-tab${activeTab === index ? '_active' : ''}`} key={tab.props.title} onClick={() => setActiveTab(index)}>
22+
{tab.props.icon && <i className={`TabGroup-icon fa ${tab.props.icon}`} style={{ color: `${tab.props.iconColor}` }}></i>}
2223
{tab.props.title}
2324
</button>
2425
)}

components/Tabs/style.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
}
3434
}
3535

36+
&-icon {
37+
color: var(--project-color-primary, inherit);
38+
margin-right: 10px;
39+
}
40+
3641
.TabContent {
3742
color: var(--color-text-muted, #4f5a66);
3843
}

0 commit comments

Comments
 (0)