Skip to content

Commit c08ada3

Browse files
authored
Merge pull request #3919 from Blargian/fix_css
Add wrapper component to handle wide tables
2 parents 5cc76b9 + 377eedd commit c08ada3

File tree

5 files changed

+140
-2
lines changed

5 files changed

+140
-2
lines changed

docs/integrations/language-clients/java/client/_snippets/_v0_8.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Tabs from '@theme/Tabs';
22
import TabItem from '@theme/TabItem';
3+
import WideTableWrapper from '@site/src/components/WideTableWrapper/WideTableWrapper';
34

45
Java client library to communicate with a DB server through its protocols. The current implementation only supports the [HTTP interface](/interfaces/http).
56
The library provides its own API to send requests to a server. The library also provides tools to work with different binary data formats (RowBinary* & Native*).
@@ -104,7 +105,7 @@ Major configuration parameters are defined in one scope (client or operation) an
104105
Configuration is defined during client creation. See `com.clickhouse.client.api.Client.Builder`.
105106

106107
## Client Configuration {#client-configuration}
107-
108+
<WideTableWrapper>
108109
| Configuration Method | Arguments | Description |
109110
|---------------------------------------|:-----------------------------------------------|:--------------------------------------------|
110111
| `addEndpoint(String endpoint)` | - `enpoint` - URL formatted a server address. | Adds a server endpoint to list of available servers. Currently only one endpoint is supported. |
@@ -160,6 +161,7 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
160161
| `useHTTPBasicAuth(boolean useBasicAuth)` | - `useBasicAuth` - flag that indicates if the option should be enabled | Sets if basic HTTP authentication should be used for user-password authentication. Default is enabled. Using this type of authentication resolves issues with passwords containing special characters that cannot be transferred over HTTP headers. |
161162
| `setClientName(String clientName)` | - `clientName` - a string representing application name | Sets additional information about calling application. This string will be passed to server as a client name. In case of HTTP protocol it will be passed as a `User-Agent` header. |
162163
| `useBearerTokenAuth(String bearerToken)` | - `bearerToken` - an encoded bearer token | Specifies whether to use Bearer Authentication and what token to use. The token will be sent as is, so it should be encoded before passing to this method. |
164+
</WideTableWrapper>
163165

164166
## Common Definitions {#common-definitions}
165167

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React, { useRef, useEffect } from 'react';
2+
import styles from './styles.module.scss';
3+
4+
const WideTableWrapper = ({ children }) => {
5+
const topScrollRef = useRef(null);
6+
const bottomScrollRef = useRef(null);
7+
const topScrollContentRef = useRef(null);
8+
const tableRef = useRef(null);
9+
10+
useEffect(() => {
11+
const topScroll = topScrollRef.current;
12+
const bottomScroll = bottomScrollRef.current;
13+
const topScrollContent = topScrollContentRef.current;
14+
const table = tableRef.current;
15+
16+
if (!topScroll || !bottomScroll || !topScrollContent || !table) return;
17+
18+
// Sync scroll positions
19+
const syncScrollLeft = (source, target) => {
20+
target.scrollLeft = source.scrollLeft;
21+
};
22+
23+
// Update top scroll bar width to match table content width
24+
const updateTopScrollWidth = () => {
25+
if (table.scrollWidth && topScrollContent) {
26+
topScrollContent.style.width = `${table.scrollWidth}px`;
27+
}
28+
};
29+
30+
// Event listeners for scroll synchronization
31+
const handleTopScroll = () => syncScrollLeft(topScroll, bottomScroll);
32+
const handleBottomScroll = () => syncScrollLeft(bottomScroll, topScroll);
33+
34+
topScroll.addEventListener('scroll', handleTopScroll);
35+
bottomScroll.addEventListener('scroll', handleBottomScroll);
36+
37+
// Initial width update and observe changes
38+
updateTopScrollWidth();
39+
40+
const resizeObserver = new ResizeObserver(updateTopScrollWidth);
41+
resizeObserver.observe(table);
42+
43+
// Cleanup
44+
return () => {
45+
topScroll.removeEventListener('scroll', handleTopScroll);
46+
bottomScroll.removeEventListener('scroll', handleBottomScroll);
47+
resizeObserver.disconnect();
48+
};
49+
}, []);
50+
51+
return (
52+
<div className={styles.wideTableContainer}>
53+
{/* Top scroll bar */}
54+
<div
55+
ref={topScrollRef}
56+
className={styles.topScrollBar}
57+
>
58+
<div
59+
ref={topScrollContentRef}
60+
className={styles.topScrollContent}
61+
/>
62+
</div>
63+
64+
{/* Main content with bottom scroll bar */}
65+
<div
66+
ref={bottomScrollRef}
67+
className={styles.bottomScrollContainer}
68+
>
69+
<div ref={tableRef} className={styles.tableContent}>
70+
{children}
71+
</div>
72+
</div>
73+
</div>
74+
);
75+
};
76+
77+
export default WideTableWrapper;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.wideTableContainer {
2+
position: relative;
3+
width: 100%;
4+
margin-bottom: 2rem;
5+
}
6+
7+
.topScrollWrapper {
8+
overflow: hidden; /* Hide any overflow from the wrapper */
9+
}
10+
11+
.topScrollBar {
12+
overflow-x: auto;
13+
overflow-y: hidden;
14+
height: 20px; /* Slightly larger to accommodate default scrollbar */
15+
width: 100%; /* Take full width of the wrapper */
16+
}
17+
18+
.topScrollContent {
19+
height: 1px;
20+
background: transparent;
21+
}
22+
23+
.bottomScrollContainer {
24+
overflow-x: auto;
25+
overflow-y: visible;
26+
}
27+
28+
.tableContent {
29+
width: 100%; /* Take full width first */
30+
min-width: max-content; /* Then ensure it can grow if needed */
31+
}
32+
33+
/* Handle long content in table cells */
34+
.tableContent table {
35+
width: 100% !important; /* Take full width of parent container */
36+
max-width: 100vw; /* Don't exceed viewport width */
37+
table-layout: auto; /* Let columns distribute naturally */
38+
}
39+
40+
.tableContent table thead,
41+
.tableContent table tbody {
42+
width: 100%;
43+
}
44+
45+
.tableContent table tr {
46+
width: 100%;
47+
}
48+
49+
.tableContent td,
50+
.tableContent th {
51+
max-width: 500px; /* Reasonable max width per cell */
52+
word-wrap: break-word;
53+
overflow-wrap: break-word;
54+
}
55+
56+
/* Use default system scrollbars */

src/theme/DocItem/Layout/styles.module.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
.tocSidebar {
99
justify-content: right;
1010
display: flex;
11+
width: fit-content;
12+
max-width: 350px;
1113
}
1214
}
1315

@@ -18,7 +20,7 @@
1820
}
1921

2022
.docItemContainer {
21-
max-width: 1000px;
23+
max-width: 1250px;
2224
display: flex;
2325
flex-direction: column;
2426
justify-content: space-between;

src/theme/DocItem/TOC/Desktop/styles.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
padding-bottom: 3.5rem;
2121
overflow-y: auto;
2222
top: calc(var(--ifm-navbar-height) + 1rem);
23+
max-width: 350px;
2324
}
2425
}
2526

0 commit comments

Comments
 (0)