forked from cardstack/boxel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpet.gts
58 lines (57 loc) · 1.84 KB
/
pet.gts
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
import {
contains,
field,
CardDef,
Component,
} from 'https://cardstack.com/base/card-api';
import BooleanCard from 'https://cardstack.com/base/boolean';
import NumberCard from 'https://cardstack.com/base/number';
import StringCard from 'https://cardstack.com/base/string';
import { GridContainer } from '@cardstack/boxel-ui/components';
export class Pet extends CardDef {
static displayName = 'Pet';
@field firstName = contains(StringCard);
@field favoriteToy = contains(StringCard);
@field favoriteTreat = contains(StringCard);
@field cutenessRating = contains(NumberCard);
@field sleepsOnTheCouch = contains(BooleanCard);
@field title = contains(StringCard, {
computeVia: function (this: Pet) {
return this.firstName;
},
});
@field description = contains(StringCard, {
computeVia: function (this: Pet) {
return `${this.firstName} the Pet`;
},
});
static embedded = class Embedded extends Component<typeof this> {
<template>
<GridContainer
{{! @glint-ignore Argument of type 'unknown' is not assignable to parameter of type 'Element'}}
...attributes
>
<h3><@fields.firstName /></h3>
<div>Sleeps On the Couch: <@fields.sleepsOnTheCouch /></div>
</GridContainer>
</template>
};
static isolated = class Isolated extends Component<typeof this> {
<template>
<GridContainer class='container'>
<h2><@fields.title /></h2>
<div>
<div>Sleeps On the Couch: <@fields.sleepsOnTheCouch /></div>
<div>Favorite Toy: <@fields.favoriteToy /></div>
<div>Favorite Treat: <@fields.favoriteTreat /></div>
<div>Cuteness Rating: <@fields.cutenessRating /></div>
</div>
</GridContainer>
<style>
.container {
padding: var(--boxel-sp-xl);
}
</style>
</template>
};
}