summaryrefslogtreecommitdiff
path: root/examples/todo-list/style.css
blob: 5316d41e0c927d9aca46427154cee4251d9a102e (plain) (blame)
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
:root {
  --color-gray: #cccccc;
  --color-accent: #5180e9;

  font-size: 16px;
  color: #555;

  --cssx-children: main#container;
}

#container {
  max-width: 600px;
  margin: 2rem auto;
  border: 1px solid var(--color-gray);
  border-radius: 5px;
  overflow: hidden;

  --cssx-children: form#task-input-form #task-list;
}

#task-input-form {
  display: flex;
  width: 100%;

  /* prettier-ignore */
  --cssx-on-submit:
    prevent-default()
    add-children(
      task-list,
      instance(div#task-item, map(--text: attr(text-input, 'value')))
    )
    set-attr(text-input, value, '')
  ;

  /* prettier-ignore */
  --cssx-on-mount:
    add-children(
      task-list,
      instance(div#task-item, map(--text: "Buy lemons"))
    )
    add-children(
      task-list,
      instance(div#task-item, map(--text: "Make lemonaide"))
    )
    add-children(
      task-list,
      instance(div#task-item, map(--text: "Kill all the non-believers"))
    )
  ;

  /* prettier-ignore */
  --cssx-children:
    input#text-input[placeholder="Eg: Buy Milk"]
    button#create-task-btn[type=submit]
  ;
}

#text-input {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid var(--color-gray);
}

#create-task-btn {
  padding: 0 2rem;
  background-color: var(--color-accent);
  color: white;
  font-weight: bold;
  border: none;
  font-size: 1.2rem;

  --cssx-text: '+';
}


[data-instance=task-item] {
  --text: "default text";
  --checked: "false";

  padding: 1rem;
  cursor: pointer;

  --cssx-on-click: update(--checked, if(get-var(--checked), "false", "true"));
}
[data-instance=task-item]::after {
  content: "[" var(--checked) "] " var(--text);
}

[data-instance=task-item]:not(:first-child) {
  content: "";
  display: block;
  border-top: 1px solid var(--color-gray);
}