-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathcode-editor.hbs
107 lines (97 loc) · 3.81 KB
/
code-editor.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{page-title "CodeEditor Component"}}
<Shw::Text::H1>CodeEditor</Shw::Text::H1>
<section data-test-percy>
<Shw::Text::H2>Content</Shw::Text::H2>
<Shw::Flex @direction="column" as |SF|>
<SF.Item @label="No content">
<Hds::CodeEditor />
<Hds::CodeEditor @language="bubba" />
</SF.Item>
<SF.Item @label="With initial content">
<Hds::CodeEditor @value={{this.demoCode}} />
</SF.Item>
</Shw::Flex>
<Shw::Text::H2>Header</Shw::Text::H2>
<Shw::Text::H3>Title and description</Shw::Text::H3>
<Shw::Grid @columns={{2}} @gap="2rem" as |SG|>
<SG.Item @label="With title">
<Hds::CodeEditor as |CE|>
<CE.Title>Code editor with title</CE.Title>
</Hds::CodeEditor>
</SG.Item>
<SG.Item @label="With description">
<Hds::CodeEditor as |CE|>
<CE.Description>This is a code editor with a description</CE.Description>
</Hds::CodeEditor>
</SG.Item>
<SG.Item @label="With title and description">
<Hds::CodeEditor as |CE|>
<CE.Title>Code editor with title</CE.Title>
<CE.Description>This is a code editor with a description</CE.Description>
</Hds::CodeEditor>
</SG.Item>
</Shw::Grid>
<Shw::Text::H3>Actions</Shw::Text::H3>
<Shw::Grid @columns={{2}} @gap="2rem" as |SG|>
<SG.Item @label="Fullscreen toggle">
<Hds::CodeEditor @hasFullScreenButton={{true}} />
</SG.Item>
<SG.Item @label="Copy button">
<Hds::CodeEditor @value="Copy me!" @hasCopyButton={{true}} />
</SG.Item>
<SG.Item @label="Fullscreen toggle and copy button">
<Hds::CodeEditor @hasFullScreenButton={{true}} @hasCopyButton={{true}} />
</SG.Item>
</Shw::Grid>
<Shw::Text::H3>Custom content</Shw::Text::H3>
<Shw::Grid @columns={{2}} @gap="2rem" as |SG|>
<SG.Item @label="With custom header content">
<Hds::CodeEditor>
<Hds::Button @text="Custom button" @size="small" />
</Hds::CodeEditor>
</SG.Item>
</Shw::Grid>
<Shw::Text::H3>Complex examples</Shw::Text::H3>
<Shw::Grid @columns={{2}} @gap="2rem" as |SG|>
<SG.Item @label="With title, description, and internal actions">
<Hds::CodeEditor @hasFullScreenButton={{true}} @hasCopyButton={{true}} as |CE|>
<CE.Title>Code editor with title</CE.Title>
<CE.Description>This is a code editor with a description</CE.Description>
</Hds::CodeEditor>
</SG.Item>
<SG.Item @label="With title, description, and custom content">
<Hds::CodeEditor as |CE|>
<CE.Title>Code editor with title</CE.Title>
<CE.Description>This is a code editor with a description</CE.Description>
<Hds::Button @text="Custom button" @size="small" />
<Hds::Icon @name="code" @color="#fff" />
</Hds::CodeEditor>
</SG.Item>
<SG.Item @label="With title, description, internal actions, and custom content">
<Hds::CodeEditor @hasFullScreenButton={{true}} @hasCopyButton={{true}} as |CE|>
<CE.Title>Code editor with title</CE.Title>
<CE.Description>This is a code editor with a description</CE.Description>
<Hds::Button @text="Custom button" @size="small" />
<Hds::Icon @name="code" @color="#fff" />
</Hds::CodeEditor>
</SG.Item>
</Shw::Grid>
<Shw::Text::H2>Syntax highlighting</Shw::Text::H2>
<Shw::Grid @columns={{2}} @gap="2rem" as |SG|>
{{#each this.languages as |lang|}}
<SG.Item @label={{lang.label}}>
<Hds::CodeEditor @language={{lang.value}} @value={{lang.code}} />
</SG.Item>
{{/each}}
</Shw::Grid>
<Shw::Text::H2>Standalone modifier usage</Shw::Text::H2>
<Shw::Flex @direction="column" as |SF|>
<SF.Item @label="`div` element with `hds-code-editor` modifier">
<div {{hds-code-editor value=this.demoCode}} />
</SF.Item>
</Shw::Flex>
</section>