Skip to content

Commit 6bc269c

Browse files
feat(website): add typescript specific notices
1 parent 3a9c1eb commit 6bc269c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/overmind-website/guides/beginner/05_structuringtheapp.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ But if we want to split up into actual domains it would look more like this:
2424
h(Example, { name: "guide/structuringtheapp/domains" })
2525
```
2626

27-
In this case each domain **index** file bring its own state, actions and effects together and the **app/index** file is responsible for bringing the configuration together.
27+
In this case each domain **index** file bring its own state, actions and effects together and the **overmind/index** file is responsible for bringing the configuration together.
28+
29+
```marksy
30+
h(TypescriptNotice, null, "Note that you do not define a **Config**, **Action** etc. type for each domain of your application. Only the main file that instantiates Overmind has this typing. This allows all the domains of the application to know about each other.")
31+
```
2832

2933
## The state file
3034

packages/overmind-website/src/utils.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createElement, useState, useEffect } from 'react'
22
import { useOvermind } from './overmind'
33
import marksy from 'marksy'
44
import * as Prism from '../src/prismjs.js'
5+
import * as tsLogo from './images/ts.png'
56
import { css } from 'emotion'
67

78
export const viewport = {
@@ -50,6 +51,7 @@ const githubLink = css`
5051
`
5152

5253
const notice = css`
54+
position: relative;
5355
background-color: var(--color-white-2);
5456
border: 1px solid var(--color-primary);
5557
border-left: 6px solid var(--color-primary);
@@ -58,6 +60,18 @@ const notice = css`
5860
font-size: var(--font-size-3);
5961
`
6062

63+
const typescriptNotice = css`
64+
border: 1px solid #007acc;
65+
border-left: 6px solid #007acc;
66+
`
67+
68+
const tsLogoStyle = css`
69+
position: absolute;
70+
top: 0;
71+
left: 0;
72+
border-bottom-right-radius: var(--border-radius-1);
73+
`
74+
6175
const contentWrapper = css`
6276
position: relative;
6377
@media (max-width: 700px) {
@@ -152,6 +166,19 @@ export const compile = marksy({
152166
Notice: ({ children }) => {
153167
return <div className={notice}>{compile(String(children)).tree}</div>
154168
},
169+
TypescriptNotice: ({ children }) => {
170+
const { state } = useOvermind()
171+
if (!state.typescript) {
172+
return null
173+
}
174+
175+
return (
176+
<div className={css(notice, typescriptNotice)}>
177+
{compile(String(children)).tree}
178+
<img className={tsLogoStyle} src={tsLogo} width="20" />
179+
</div>
180+
)
181+
},
155182
},
156183
elements: {
157184
a({ href, children }) {

0 commit comments

Comments
 (0)