Skip to content

Commit 2b9b239

Browse files
committed
structure for notes types
1 parent 2ae1381 commit 2b9b239

File tree

6 files changed

+84
-21
lines changed

6 files changed

+84
-21
lines changed

functions/Element/setElementHealth.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ shared: &shared
88
description: |
99
This function sets the health of a [player](/player), [ped](/ped), [vehicle](/vehicle), or [object](/object) element.
1010
notes:
11-
- |
12-
In the case of the [vehicle](/vehicle) element, the health ranges from 0 to 1000.
13-
14-
- *1000:* no damage at all
15-
- *650:* white steam 0%, black smoke 0%
16-
- *450:* white steam 100%, black smoke 50%
17-
- *250:* white steam 0%, black smoke 100%
18-
- *249:* fire with big black smoke (blowing up)
11+
- type: 'standard'
12+
content: |
13+
In the case of the [vehicle](/vehicle) element, the health ranges from 0 to 1000.
14+
15+
- *1000:* no damage at all
16+
- *650:* white steam 0%, black smoke 0%
17+
- *450:* white steam 100%, black smoke 50%
18+
- *250:* white steam 0%, black smoke 100%
19+
- *249:* fire with big black smoke (blowing up)
1920
parameters:
2021
- name: 'theElement'
2122
type: 'element'

schemas/common-defs.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@ type: object
55
$defs:
66
notes:
77
type: array
8-
description: List of noteworthy pieces of information for the item.
8+
description: |
9+
List of noteworthy pieces of information for the item.
10+
Each note can be of a specific type, e.g., 'standard' or 'important'.
911
items:
10-
type: string
12+
type: object
13+
description: An individual note item.
14+
required:
15+
- content
16+
properties:
17+
type:
18+
type: string
19+
description: The type of the note, influencing its presentation.
20+
enum:
21+
- standard
22+
- important
23+
default: standard
24+
content:
25+
type: string
26+
description: The textual content of the note. Can use markdown and YAML multi-line strings.
1127

1228
meta:
1329
type: array

web/src/components/NoteBox.astro

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
---
2+
import type { HTMLAttributes } from 'astro/types';
3+
4+
interface Props extends HTMLAttributes<'div'> {
5+
type?: 'standard' | 'important';
6+
}
7+
8+
const { type = 'standard', class: className, ...rest } = Astro.props;
29
---
3-
<div class="custom-note-box">
10+
<div
11+
class:list={["custom-note-box", { 'note-important': type === 'important' }, className]}
12+
{...rest}
13+
>
14+
{type === 'important' && (
15+
<span class="note-icon" aria-label="Importante">
16+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" aria-hidden="true">
17+
<circle cx="10" cy="10" r="10" fill="#e53935"/>
18+
<text x="10" y="15" text-anchor="middle" font-size="14" fill="#fff" font-family="Arial" font-weight="bold">!</text>
19+
</svg>
20+
</span>
21+
)}
422
<slot />
523
</div >
624

@@ -12,8 +30,34 @@
1230
padding: 1rem 1.25rem;
1331
margin-bottom: 1rem;
1432
color: var(--sl-color-text);
33+
position: relative;
1534
}
35+
1636
html[data-theme="dark"] .custom-note-box {
1737
background-color: var(--sl-color-gray-5);
1838
}
39+
40+
.custom-note-box.note-important {
41+
background-color: var(--sl-color-red-low);
42+
border-left-color: #d32f2f;
43+
}
44+
45+
html[data-theme="dark"] .custom-note-box.note-important {
46+
--sl-color-red-low: hsl(var(--sl-color-red-hue), 50%, 20%);
47+
}
48+
49+
.note-icon {
50+
position: absolute;
51+
top: 0.75rem;
52+
right: 0.75rem;
53+
z-index: 1;
54+
display: flex;
55+
align-items: center;
56+
justify-content: center;
57+
pointer-events: none;
58+
}
59+
.custom-note-box.note-important {
60+
padding-right: 2.5rem;
61+
padding-left: 1.25rem;
62+
}
1963
</style>

web/src/pages/[func].astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Code } from '@astrojs/starlight/components';
99
1010
import NoteBox from '@src/components/NoteBox.astro';
1111
import '@src/styles/function-page.css';
12+
import type { NotesType } from '@src/utils/types';
1213
1314
export async function getStaticPaths() {
1415
const functions = await getCollection('functions');
@@ -41,7 +42,7 @@ if (Array.isArray(rawExamples) && rawExamples.length > 0) {
4142
});
4243
}
4344
44-
let notesContent: string[] = [];
45+
let notesContent: NotesType = [];
4546
if (Array.isArray(funcNotes) && funcNotes.length > 0) {
4647
notesContent = funcNotes;
4748
}
@@ -65,8 +66,8 @@ if (Array.isArray(funcNotes) && funcNotes.length > 0) {
6566
<!-- Notes -->
6667
<div class="notes-section">
6768
{notesContent.map((note) => (
68-
<NoteBox>
69-
<Fragment set:html={marked(note)} />
69+
<NoteBox type={note.type}>
70+
<Fragment set:html={marked(note.content)} />
7071
</NoteBox>
7172
))}
7273
</div>

web/src/utils/functions.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getCollection } from 'astro:content';
22
import path from 'path';
33

4-
import type { FunctionType } from './types';
4+
import type { FunctionType, NotesType } from './types';
55

66
type FunctionItem = Awaited<ReturnType<typeof getCollection>>[number];
77

@@ -15,8 +15,7 @@ type FunctionDetails = {
1515
description?: string;
1616
pair?: boolean;
1717
examples?: { code: string; description?: string }[];
18-
notes?: string[];
19-
important_notes?: string[];
18+
notes?: NotesType;
2019
parameters?: FunctionParameter[];
2120
};
2221

@@ -62,8 +61,7 @@ export type FunctionInfo = {
6261
typePretty: string;
6362
pair: boolean;
6463
examples: { code: string; description?: string }[];
65-
notes?: string[];
66-
important_notes?: string[];
64+
notes?: NotesType;
6765
parameters?: FunctionParameter[];
6866
};
6967

@@ -78,7 +76,6 @@ export function getFunctionInfo(data: TypedFunctionData): FunctionInfo {
7876
pair: details.pair || false,
7977
examples: details.examples || [],
8078
notes: details.notes || [],
81-
important_notes: details.important_notes || [],
8279
parameters: details.parameters || [],
8380
};
8481
}

web/src/utils/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export type FunctionType = 'shared' | 'client' | 'server';
1+
export type FunctionType = 'shared' | 'client' | 'server';
2+
export type NotesType = {
3+
type: 'standard' | 'important';
4+
content: string;
5+
}[];

0 commit comments

Comments
 (0)