Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC-324: Fix broken responsiveness #1099

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading