103 |
114 | {values.map(({ value, label }) => (
115 | - tabRefs.push(tabControl)}
124 | onKeyDown={handleKeydown}
125 | onFocus={handleTabChange}
126 | onClick={handleTabChange}
127 | >
128 | {label}
129 |
130 | ))}
131 |
132 |
133 | {lazy ? (
134 | cloneElement(
135 | children.filter(
136 | (tabItem) => tabItem.props.value === selectedValue
137 | )[0],
138 | { className: "my-4" }
139 | )
140 | ) : (
141 |
142 | {children.map((tabItem, i) =>
143 | cloneElement(tabItem, {
144 | key: i,
145 | hidden: tabItem.props.value !== selectedValue,
146 | })
147 | )}
148 |
149 | )}
150 |
151 | );
152 | }
153 |
154 | export default Tabs;
155 |
--------------------------------------------------------------------------------
/src/theme/Tabs/styles.module.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | .tabItem {
9 | margin-top: 0 !important;
10 | }
11 |
12 | .tabItemActive {
13 | animation: blink 0.5s ease-in-out 5;
14 | }
15 |
16 | @keyframes blink {
17 | 0% {
18 | background-color: var(--ifm-hover-overlay);
19 | }
20 | 100% {
21 | background-color: rgba(0, 0, 0, 0);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/theme/ThemeContext.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | import React from 'react';
9 | import type {ThemeContextProps} from '@theme/hooks/useThemeContext';
10 |
11 | const ThemeContext = React.createContext