Skip to content

Commit 25eddf1

Browse files
committed
chore: Temporarily added realistic examples for handlebars, javascript, and typescript
1 parent 7822430 commit 25eddf1

File tree

4 files changed

+158
-17
lines changed

4 files changed

+158
-17
lines changed

lib/rouge/demos/handlebars

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,70 @@
1-
<div class="entry">
2-
<h1>{{title}}</h1>
3-
{{#with story}}
4-
<div class="intro">{{{intro}}}</div>
5-
<div class="body">{{{body}}}</div>
6-
{{/with}}
7-
</div>
1+
{{#let (unique-id) as |formId|}}
2+
<form
3+
aria-describedby={{if
4+
@instructions
5+
(concat formId "-instructions")
6+
}}
7+
aria-labelledby={{if @title (concat formId "-title")}}
8+
class={{this.styles.form}}
9+
data-test-form={{if @title @title ""}}
10+
{{autofocus}}
11+
{{on "submit" this.submitForm}}
12+
>
13+
<Ui::Form::Information
14+
@formId={{formId}}
15+
@instructions={{@instructions}}
16+
@title={{@title}}
17+
/>
18+
19+
<ContainerQuery
20+
@features={{hash wide=(width min=480)}}
21+
as |CQ|
22+
>
23+
{{yield
24+
(hash
25+
Checkbox=(component
26+
"ui/form/checkbox"
27+
data=this.data
28+
isInline=true
29+
isWide=CQ.features.wide
30+
onUpdate=this.updateData
31+
)
32+
Input=(component
33+
"ui/form/input"
34+
data=this.data
35+
isWide=CQ.features.wide
36+
onUpdate=this.updateData
37+
)
38+
Number=(component
39+
"ui/form/number"
40+
data=this.data
41+
isWide=CQ.features.wide
42+
onUpdate=this.updatedata
43+
)
44+
Select=(component
45+
"ui/form/select"
46+
data=this.data
47+
isWide=CQ.features.wide
48+
onUpdate=this.updatedata
49+
)
50+
Textarea=(component
51+
"ui/form/textarea"
52+
data=this.data
53+
isWide=CQ.features.wide
54+
onUpdate=this.updatedata
55+
)
56+
)
57+
}}
58+
</ContainerQuery>
59+
60+
<div class={{this.styles.actions}}>
61+
<button
62+
class={{this.styles.submit-button}}
63+
data-test-button="Submit"
64+
type="submit"
65+
>
66+
{{t "components.ui.form.submit"}}
67+
</button>
68+
</div>
69+
</form>
70+
{{/let}}

lib/rouge/demos/javascript

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
$(document).ready(function() { alert('ready!'); });
1+
import { action } from '@ember/object';
2+
import Component from '@glimmer/component';
3+
import { TrackedObject } from 'tracked-built-ins';
4+
5+
import styles from './form.css';
6+
7+
export default class UiForm extends Component {
8+
data = new TrackedObject(this.args.data ?? {});
9+
styles = styles;
10+
11+
@action async submitForm(event) {
12+
event.preventDefault();
13+
14+
await this.args.onSubmit(this.data);
15+
}
16+
17+
@action updateData({ key, value }) {
18+
this.data[key] = value;
19+
}
20+
}

lib/rouge/demos/typescript

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
$(document).ready(function() { alert('ready!'); });
1+
import { action } from '@ember/object';
2+
import Component from '@glimmer/component';
3+
import type { WithBoundArgs } from '@glint/template';
4+
import { TrackedObject } from 'tracked-built-ins';
5+
6+
import styles from './form.css';
7+
import UiFormCheckbox from './form/checkbox.gts';
8+
import UiFormInput from './form/input.gts';
9+
import UiFormNumber from './form/number.gts';
10+
import UiFormSelect from './form/select.gts';
11+
import UiFormTextarea from './form/textarea.gts';
12+
13+
interface UiFormSignature {
14+
Args: {
15+
data?: Record<string, unknown>;
16+
instructions?: string;
17+
onSubmit: (data: Record<string, unknown>) => Promise<void>;
18+
title?: string;
19+
};
20+
Blocks: {
21+
default: [
22+
{
23+
Checkbox: WithBoundArgs<
24+
typeof UiFormCheckbox,
25+
'data' | 'isInline' | 'isWide' | 'onUpdate'
26+
>;
27+
Input: WithBoundArgs<
28+
typeof UiFormInput,
29+
'data' | 'isWide' | 'onUpdate'
30+
>;
31+
Number: WithBoundArgs<
32+
typeof UiFormNumber,
33+
'data' | 'isWide' | 'onUpdate'
34+
>;
35+
Select: WithBoundArgs<
36+
typeof UiFormSelect,
37+
'data' | 'isWide' | 'onUpdate'
38+
>;
39+
Textarea: WithBoundArgs<
40+
typeof UiFormTextarea,
41+
'data' | 'isWide' | 'onUpdate'
42+
>;
43+
},
44+
];
45+
};
46+
}
47+
48+
export default class UiForm extends Component<UiFormSignature> {
49+
data = new TrackedObject<Record<string, unknown>>(this.args.data ?? {});
50+
styles = styles;
51+
52+
@action async submitForm(event: SubmitEvent): Promise<void> {
53+
event.preventDefault();
54+
55+
await this.args.onSubmit(this.data);
56+
}
57+
58+
@action updateData({ key, value }: { key: string; value: unknown }): void {
59+
this.data[key] = value;
60+
}
61+
}

spec/visual/templates/index.erb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<style type="text/css">
2+
code {
3+
font-size: 14px;
4+
}
25
main {
3-
padding: 15px;
4-
column-count: 2;
5-
-webkit-column-count: 2;
6-
-moz-column-count: 2;
6+
display: flex;
7+
flex-direction: row;
78
}
89
.preview {
9-
display: inline-block;
10-
margin-bottom: 15px;
11-
padding: 15px;
10+
padding: 16px;
1211
width: 100%;
1312
color: <%= @comment_color %>;
14-
border: 1px dotted;
13+
border: 0.5px dotted;
1514
break-inside: avoid-column;
1615
-webkit-column-break-inside: avoid;
1716
}

0 commit comments

Comments
 (0)