Ver Código Fonte

Add some CSS

Lucas Stadler 8 anos atrás
pai
commit
091cc71ba9
1 arquivos alterados com 61 adições e 2 exclusões
  1. 61 2
      quit.go

+ 61 - 2
quit.go

@ -23,6 +23,7 @@ func main() {
23 23
		err = repoTmpl.Execute(buf, map[string]interface{}{
24 24
			"RepoPath": "~/t/libgit2",
25 25
			"Repo":     NewFancyRepo(repo),
26
			"Style":    template.CSS(repoStyle),
26 27
		})
27 28
		if err != nil {
28 29
			log.Println("rendering repo: ", err)
@ -141,6 +142,7 @@ var repoTmpl = template.Must(template.New("").Parse(`<!doctype html>
141 142
	<head>
142 143
		<meta charset="utf-8" />
143 144
		<title>{{ .RepoPath }}</title>
145
		<style>{{ .Style }}</style>
144 146
	</head>
145 147
146 148
	<body>
@ -151,12 +153,69 @@ var repoTmpl = template.Must(template.New("").Parse(`<!doctype html>
151 153
			<time class="commit-date">{{ .Repo.Commit.Date }}</time>
152 154
		</section>
153 155
154
		<table class="files">
156
		<table id="files">
155 157
			{{ range $file := .Repo.Commit.Files }}
156 158
			<tr class="file">
157
				<td class="file-type-{{ $file.Type }}">{{ $file.Name }}</td>
159
				<td class="file-name file-type-{{ $file.Type }}">{{ $file.Name }}</td>
158 160
			</tr>
159 161
			{{ end }}
160 162
	</body>
161 163
</html>
162 164
`))
165
166
var repoStyle = `
167
body {
168
  font-family: Arial, sans-serif;
169
}
170
171
#commit {
172
  display: flex;
173
  justify-content: space-between;
174
  align-items: baseline;
175
  padding: 0.6em 0.5em;
176
  width: 70vw;
177
  background-color: rgba(200, 0, 255, 0.15);
178
}
179
180
#commit .commit-author {
181
  font-weight: 600;
182
}
183
184
#commit .commit-id {
185
  font-family: monospace;
186
}
187
188
#files td {
189
  border: 1px solid #333;
190
  border-radius: 2px;
191
  margin-bottom: 0;
192
  padding: 0.2em 0.5em;
193
  font-size: 95%;
194
}
195
196
#files tr:hover {
197
  background-color: #efefef;
198
}
199
200
#files {
201
  width: 70vw;
202
}
203
204
.file-name {
205
  color: #00445a;
206
}
207
208
.file-type-blob:before {
209
  content:"🖹";
210
  padding-right: 0.5em;
211
}
212
213
.file-type-tree:before {
214
  content: "🗀";
215
  padding-right: 0.2em;
216
}
217
218
.file-type-tree:after {
219
  content: "/";
220
}
221
`