Skip to content

Commit 265a947

Browse files
docs(website): update with new guide and fix some styling
1 parent 29a0bd5 commit 265a947

File tree

6 files changed

+156
-5
lines changed

6 files changed

+156
-5
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { tsAppIndex } from '../../templates'
2+
3+
export default (ts, view) =>
4+
ts
5+
? [
6+
{
7+
code: `
8+
app/
9+
posts/
10+
state.ts
11+
actions.ts
12+
effects.ts
13+
reactions.ts
14+
index.ts
15+
admin/
16+
state.ts
17+
actions.ts
18+
effects.ts
19+
reactions.ts
20+
index.ts
21+
index.ts
22+
`,
23+
},
24+
]
25+
: [
26+
{
27+
code: `
28+
app/
29+
posts/
30+
state.js
31+
actions.js
32+
effects.js
33+
reactions.js
34+
index.js
35+
admin/
36+
state.js
37+
actions.js
38+
effects.js
39+
reactions.js
40+
index.js
41+
index.js
42+
`,
43+
},
44+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { tsAppIndex } from '../../templates'
2+
3+
export default (ts, view) =>
4+
ts
5+
? [
6+
{
7+
code: `
8+
app/
9+
state.ts
10+
actions.ts
11+
effects.ts
12+
reactions.ts
13+
index.ts
14+
`,
15+
},
16+
]
17+
: [
18+
{
19+
code: `
20+
app/
21+
state.js
22+
actions.js
23+
effects.js
24+
reactions.js
25+
index.js
26+
`,
27+
},
28+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export default (ts, view) =>
2+
ts
3+
? [
4+
{
5+
fileName: 'app/index.ts',
6+
code: `
7+
import { Overmind, TApp } from 'overmind'
8+
import { namespaced } from 'overmind/config'
9+
import * as posts from './posts'
10+
import * as admin from './admin'
11+
12+
const config = namespaced({
13+
posts,
14+
admin
15+
})
16+
17+
declare module 'overmind' {
18+
interface IApp extends TApp<typeof config> {}
19+
}
20+
21+
const app = new Overmind(config)
22+
`,
23+
},
24+
]
25+
: [
26+
{
27+
fileName: 'app/index.js',
28+
code: `
29+
import { Overmind } from 'overmind'
30+
import { namespaced } from 'overmind/config'
31+
import * as posts from './posts'
32+
import * as admin from './admin'
33+
34+
const config = namespaced({
35+
posts,
36+
admin
37+
})
38+
39+
const app = new Overmind(config)
40+
`,
41+
},
42+
]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Structuring the app
2+
3+
You will quickly see the need to give more structure to your application. The base structure of
4+
5+
`{ state, actions, effects, reactions }`
6+
7+
does not scale very well.
8+
9+
The before mentioned base structure is called **the configuration** of your application and tools are provided to create more complex configurations. But before we look at those tools, lets talk about file structure.
10+
11+
## Domains
12+
13+
As your application grows you start to separate it into different domains. A domain might be closely related to a page in your application, or maybe it is strictly related to managing some piece of data. It does not matter. You define the domains of your application and they probably change over time as well. What matters in the context of Overmind though is that each of these domains will container their own state, actions, effects and reactions. So imagine a file structure of:
14+
15+
```marksy
16+
h(Example, { name: "guide/structuringtheapp/files" })
17+
```
18+
19+
In this structure we are splitting up the differet components of the base structure. This is a good first step. The **index** file acts as the file that brings the state, actions, effects and reactions together. In this example the file would also be responsible for instantiating the application itself.
20+
21+
But if we want to split up into actual domains it would look more like this:
22+
23+
```marksy
24+
h(Example, { name: "guide/structuringtheapp/domains" })
25+
```
26+
27+
In this cause each domain **index** file bring its own state, actions, effects, and reactions together and the **app/index** file is responsible for bringing the configuration together. Let us look at how that can be accomplished.
28+
29+
```marksy
30+
h(Example, { name: "guide/structuringtheapp/namespaced" })
31+
```
32+
33+
We used the **namespaced** function to put the state, actions, effects and reactions from each domain behind a key. In this case the key is the same as the name of the domain itself. This is an effective way to split up your app.
34+
35+
```marksy
36+
h(Notice, null, "Even though you split up into different domains each domain has access to the state of the whole application. This is an important feature of Overmind which allows you to scale up and explore the domains of the application without having to worry about isolation")
37+
```

packages/overmind-website/src/components/GuideToc/elements.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const Wrapper = styled.div`
44
position: fixed;
55
top: 100px;
66
left: calc(50vw + 400px);
7-
color: ${({ theme }) => theme.color.fade(theme.color.black, 0.5)};
7+
color: ${({ theme }) => theme.color.fade(theme.color.black, 0.2)};
88
99
ul {
1010
list-style-type: none;

packages/overmind-website/src/components/TopBar/elements.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export const Wrapper = styled.div`
1616

1717
export const Link = styled<{ selected?: boolean }, 'a'>('a')`
1818
text-decoration: none;
19-
color: ${({ selected, theme }) =>
20-
selected ? theme.color.primary : theme.color.fade(theme.color.black, 0.5)};
19+
color: ${({ theme }) => theme.color.black};
20+
border-bottom: 2px solid
21+
${({ selected, theme }) => (selected ? theme.color.primary : 'transparent')};
2122
font-weight: ${({ selected }) => (selected ? 'bold' : 'normal')};
2223
margin: ${({ theme }) => theme.padding.small};
2324
cursor: pointer;
2425
text-transform: uppercase;
2526
:hover {
26-
color: ${({ selected, theme }) =>
27-
selected ? theme.color.primary : theme.color.black};
27+
color: ${({ theme }) => theme.color.fade(theme.color.black, 0.2)};
2828
}
2929
`

0 commit comments

Comments
 (0)