Skip to content

Commit

Permalink
DOC-324: Fix broken responsiveness (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekwuno authored Jan 6, 2025
1 parent 4ce0b98 commit 8864737
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 143 deletions.
7 changes: 5 additions & 2 deletions src/components/shared/MarkdownContainer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,16 @@ const { class: className } = Astro.props;
}
}
}

& :global(:not(pre)) :global(code) {
@apply rounded bg-code px-1.5 text-text/80 inline-block;
@apply rounded bg-code px-1.5 text-text/80 inline-block max-w-full;

& :global(.code-container) {
@apply overflow-x-auto;
}

@media (max-width: 640px) {
@apply break-words whitespace-pre-wrap;
}
}

& :global(ul) {
Expand Down
74 changes: 51 additions & 23 deletions src/components/shared/Table.astro
Original file line number Diff line number Diff line change
@@ -1,33 +1,61 @@
---
type Props = Record<string | number | symbol, unknown>;
interface Props {
class?: string;
headClass?: string;
bodyClass?: string;
rowClass?: string;
cellClass?: string;
}
const {
class: className = '',
headClass = '',
bodyClass = '',
rowClass = '',
cellClass = '',
...rest
} = Astro.props;
---

<responsive-table class="contents">
<table {...Astro.props}>
<slot />
</table>
<responsive-table class="w-full overflow-x-auto">
<table class:list={["min-w-full table-auto", className]} {...rest}>
<slot />
</table>
</responsive-table>

<script>
class ResponsiveTable extends HTMLElement {
connectedCallback() {
const headRow = this.querySelector('thead tr');
const tbody = this.querySelector('tbody');
<style>
@media (max-width: 640px) {
responsive-table {
display: block;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
}
responsive-table table thead {
display: none;
}
</style>

if (headRow && tbody) {
const headCells = Array.from(headRow.children);
const bodyRows = Array.from(tbody.children);
<script>
class ResponsiveTable extends HTMLElement {
connectedCallback() {
const headRow = this.querySelector('thead tr');
const tbody = this.querySelector('tbody');

bodyRows.forEach(row => {
const cells = Array.from(row.children);
if (headRow && tbody) {
const headCells = Array.from(headRow.children);
const bodyRows = Array.from(tbody.children);

cells.forEach((cell, index) => {
cell.setAttribute('data-label', headCells[index].textContent ?? '');
});
});
}
}
bodyRows.forEach(row => {
const cells = Array.from(row.children);
cells.forEach((cell, index) => {
cell.setAttribute('data-label', headCells[index].textContent ?? '');
});
});
}
}
}

customElements.define('responsive-table', ResponsiveTable);
</script>
customElements.define('responsive-table', ResponsiveTable);
</script>
5 changes: 3 additions & 2 deletions src/content/doc-surrealql/functions/database/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ description: SurrealDB comes with a large number of in-built functions for check
---

import Since from '@components/shared/Since.astro'
import Table from '@components/shared/Table.astro'

# Database Functions

SurrealDB has many built-in functions designed to handle many common database tasks and work with SurrealDB's various data types, grouped into modules based on their purpose and the data types they are designed to work with. The table below lists all of SurrealDB's function modules, with descriptions and links to their own detailed documentation.

<table>
<Table>
<thead>
<tr>
<th scope="col" style={{width: '20%'}}>Function</th>
Expand Down Expand Up @@ -112,7 +113,7 @@ SurrealDB has many built-in functions designed to handle many common database ta
<td scope="row" data-label="Description and Example">A collection of essential vector operations that provide foundational functionality for numerical computation, machine learning, and data analysis.<br/>Example: <code>vector::add([1, 2, 3], [1, 2, 3])</code></td>
</tr>
</tbody>
</table>
</Table>

## How to use database functions

Expand Down
Loading

0 comments on commit 8864737

Please sign in to comment.