Skip to content

Commit

Permalink
remove font bolding on hover and fix error with build
Browse files Browse the repository at this point in the history
  • Loading branch information
LadyBluenotes committed Sep 21, 2024
1 parent 27dfc48 commit b443362
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
18 changes: 16 additions & 2 deletions src/routes/solid-router/reference/data-apis/action.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
title: action
---
Expand All @@ -20,6 +19,7 @@ const myAction = action(async (data) => {

//or
<button type="submit" formaction={myAction}></button>

```

Actions only work with **post** requests.
Expand All @@ -41,6 +41,7 @@ const deleteTodo = action(async (formData: FormData) => {
<input type="hidden" name="id" value={todo.id} />
<button type="submit">Delete</button>
</form>

```

Using `with`:
Expand All @@ -56,6 +57,7 @@ const deleteTodo = action(async (formData: FormData) => {
<form action={deleteTodo.with(todo.id)} method="post">
<button type="submit">Delete</button>
</form>

```

## Notes of `<form>` implementation and SSR
Expand All @@ -76,6 +78,7 @@ This is how router context is created.
// in component
const submit = useAction(myAction);
submit(...args);

```

The outside of a form context can use custom data instead of `formData`.
Expand All @@ -100,11 +103,14 @@ type Submission<T, U> = {

const submissions = useSubmissions(action, (input) => filter(input));
const submission = useSubmission(action, (input) => filter(input));

```

## Revalidate cached functions

### Revalidate all (default)
By default all cached functions will be revalidated wether the action does not return or return a "normal" response.

```jsx

const deleteTodo = action(async (formData: FormData) => {
Expand Down Expand Up @@ -138,10 +144,12 @@ const deleteTodo = action(async (formData: FormData) => {
return redirect("/", { revalidate: ["getAllTodos", getTodos.key, getTodoByID.keyFor(id)]})

})

```

Prevent revalidation
## Prevent revalidation
To opt out of any revalidation you can pass any `string` to revalidate which is not a key of any cached function.

```jsx
const deleteTodo = action(async (formData: FormData) => {
const id = Number(formData.get("id"))
Expand All @@ -155,13 +163,18 @@ const deleteTodo = action(async (formData: FormData) => {
// or redirect without revalidating
return redirect("/", { revalidate: "nothing" })
})

```

### Revalidate without action

Cached functions can also be revalidated by the `revalidate` helper.

```jsx
revalidate([getTodos.key, getTodoByID.keyFor(id)])

```

This is also great if you want to set your own "refresh" interval e.g. poll data every 30 seconds.

```jsx
Expand All @@ -177,4 +190,5 @@ export default function TodoLayout(){

// ...
}

```
2 changes: 1 addition & 1 deletion src/ui/edit-page-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const EditPageLink: Component = () => {
});
return (
<a
class="flex no-underline hover:font-bold hover:text-blue-700 dark:hover:text-blue-300 dark:text-slate-300 "
class="flex no-underline hover:text-blue-700 dark:hover:text-blue-300 dark:text-slate-300 "
href={srcPath()}
target="_blank"
>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/layout/main-navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function MainNavigation(props: NavProps) {
<Tabs.List class="sticky top-0 grid grid-cols-2 w-full z-10 md:dark:bg-slate-900 md:bg-slate-50">
<Tabs.Trigger
value="learn"
class="inline-block py-3 outline-none hover:bg-blue-500/30 dark:hover:bg-blue-300/20 dark:focus-visible:bg-blue-800 dark:text-slate-100 hover:font-bold font-medium"
class="inline-block py-3 outline-none hover:bg-blue-500/30 dark:hover:bg-blue-300/20 dark:focus-visible:bg-blue-800 dark:text-slate-100 font-medium"
onClick={() => {
setSelectedTab("learn");
}}
Expand All @@ -181,7 +181,7 @@ export function MainNavigation(props: NavProps) {
</Tabs.Trigger>
<Tabs.Trigger
value="reference"
class="inline-block py-3 outline-none hover:bg-blue-500/30 dark:hover:bg-blue-300/20 dark:focus-visible:bg-blue-800 dark:text-slate-100 hover:font-bold font-medium"
class="inline-block py-3 outline-none hover:bg-blue-500/30 dark:hover:bg-blue-300/20 dark:focus-visible:bg-blue-800 dark:text-slate-100 font-medium"
onClick={() => {
setSelectedTab("reference");
}}
Expand Down
6 changes: 3 additions & 3 deletions src/ui/layout/table-of-contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const TableOfContents: Component<{ children: ResolvedChildren }> = (
"text-blue-800 dark:text-blue-300 font-bold hover:text-slate-700 dark:hover:text-slate-200":
currentSection() === "",
}}
class="no-underline hover:font-bold hover:text-slate-800"
class="no-underline hover:text-slate-800"
>
{i18n.t("toc.overview")}
</a>
Expand All @@ -119,7 +119,7 @@ export const TableOfContents: Component<{ children: ResolvedChildren }> = (
"text-blue-800 dark:text-blue-200 hover:text-slate-700 dark:hover:text-slate-200 font-bold":
currentSection() === section().id,
}}
class="no-underline hover:font-bold hover:text-slate-700 dark:hover:text-blue-300"
class="no-underline hover:text-slate-700 dark:hover:text-blue-300"
>
{section().text}
</a>
Expand All @@ -140,7 +140,7 @@ export const TableOfContents: Component<{ children: ResolvedChildren }> = (
"text-blue-800 dark:text-blue-200 hover:text-slate-700 dark:hover:text-slate-200 font-bold":
currentSection() === subSection().id,
}}
class="no-underline hover:font-bold hover:text-blue-700 dark:hover:text-blue-300"
class="no-underline hover:text-blue-700 dark:hover:text-blue-300"
>
{subSection().text}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/page-issue-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const PageIssueLink: Component = () => {
});
return (
<a
class="flex no-underline hover:font-bold hover:text-blue-700 dark:hover:text-blue-300 dark:text-slate-300 "
class="flex no-underline hover:text-blue-700 dark:hover:text-blue-300 dark:text-slate-300 "
href={srcPath()}
>
<Icon class="mr-1 w-[16px]" path={exclamationTriangle} />
Expand Down

0 comments on commit b443362

Please sign in to comment.