Skip to content

Commit 4d11a1e

Browse files
Kirill BolotskyPepe Cano
authored andcommitted
fix(components): made sure CodeGroup will render terminal header if no labels prop was passed
Exact behavior of a previous API
1 parent 6dfa88e commit 4d11a1e

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/components/shared/code/code-group.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,22 @@ const CodeGroup = ({ children, labels, lineNumbers, heightTogglers }) => {
1010
const randomKey = getRandomKey();
1111
return (
1212
<div className={styles.wrapper}>
13-
{labels && labels.length ? (
14-
<div className={styles.header}>
15-
{labels.map((label, i) => (
16-
<div
17-
key={`lb-${i}`}
18-
className={`${styles.codeTab} ${
19-
i === currentIndex ? styles.codeTab_active : ''
20-
}`}
21-
onClick={() => setCurrentIndex(i)}
22-
onKeyPress={() => setCurrentIndex(i)}
23-
role={'button'}
24-
tabIndex={i}
25-
>
26-
{label}
27-
</div>
28-
))}
29-
</div>
30-
) : null}
13+
<div className={styles.header}>
14+
{labels.map((label, i) => (
15+
<div
16+
key={`lb-${i}`}
17+
className={`${styles.codeTab} ${
18+
i === currentIndex ? styles.codeTab_active : ''
19+
}`}
20+
onClick={() => setCurrentIndex(i)}
21+
onKeyPress={() => setCurrentIndex(i)}
22+
role={'button'}
23+
tabIndex={i}
24+
>
25+
{label}
26+
</div>
27+
))}
28+
</div>
3129
<style>
3230
{`.${styles.itemsContainer}.${randomKey} > div:nth-child(${
3331
currentIndex + 1

src/components/shared/code/code-group.module.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
.header {
1414
background: $color-secondary;
15-
display: inline-flex;
15+
display: flex;
1616
flex-wrap: nowrap;
1717
color: $color-additional-1;
1818
overflow: auto;
1919
width: 100%;
2020
border-bottom: 1px solid rgba($color-tertiary, 0.05);
21+
min-height: 25px;
2122
@include no-scrollbars;
2223
}
2324

0 commit comments

Comments
 (0)