Add todo mode and replace the plan with TODO.md
This commit is contained in:
Vendored
+3
-1
@@ -5,15 +5,17 @@ import { mountInbox } from "./inbox.js";
|
||||
import { mountSettings } from "./settings.js";
|
||||
import { mountTranscript } from "./task.js";
|
||||
import { mountTasks } from "./tasks.js";
|
||||
import { mountTodo } from "./todo.js";
|
||||
const views = {
|
||||
transcript: { label: "Transcript", mount: mountTranscript },
|
||||
changes: { label: "Changes", mount: (root) => mountChanges(root) },
|
||||
tasks: { label: "Tasks", mount: mountTasks },
|
||||
todo: { label: "Todo", mount: mountTodo },
|
||||
inbox: { label: "Inbox", mount: mountInbox },
|
||||
admin: { label: "Admin", mount: mountAdmin },
|
||||
settings: { label: "Settings", mount: mountSettings },
|
||||
};
|
||||
const order = ["transcript", "changes", "tasks", "inbox", "admin", "settings"];
|
||||
const order = ["transcript", "changes", "tasks", "todo", "inbox", "admin", "settings"];
|
||||
const panes = [];
|
||||
export function openTranscript() {
|
||||
if (panes.some((p) => p.current() === "transcript")) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"panes.js","sourceRoot":"","sources":["../src/panes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC,MAAM,KAAK,GAA8E;IACvF,UAAU,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE;IAC3D,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,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AY,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;QAE9C,OAAO,CACL,IAAI,CAAC,IAAI,EACT,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC7E,CAAC,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC/B,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CACH,CAAC;QAEF,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,aAAa,IAAI,EAAE,EAAE,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAEO,UAAU;QAChB,OAAO,aAAa,IAAI,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;CACF"}
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ import { ago, errorText, h, replace, showAlert, showConfirm } from "./dom.js";
|
||||
import { markdown } from "./markdown.js";
|
||||
import { openChanges } from "./panes.js";
|
||||
import { currentSession, findTask, onEach, pinSnapshot, state } from "./state.js";
|
||||
const models = ["claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-fable-5-1"];
|
||||
export const models = ["claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-fable-5-1"];
|
||||
export function mountTranscript(root) {
|
||||
const head = h("header", { class: "task-header" });
|
||||
const transcript = h("div", { class: "transcript" });
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+121
@@ -0,0 +1,121 @@
|
||||
import { get, post } from "./api.js";
|
||||
import { errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { markdown } from "./markdown.js";
|
||||
import { openTranscript } from "./panes.js";
|
||||
import { models } from "./task.js";
|
||||
import { currentSession, on, onEach, state } from "./state.js";
|
||||
const refreshKinds = new Set(["task.merged", "project.created"]);
|
||||
export function mountTodo(root) {
|
||||
const todos = new Map();
|
||||
const starting = new Set();
|
||||
let disposed = false;
|
||||
const render = () => {
|
||||
const scrollTop = root.querySelector(".todo-view")?.scrollTop ?? 0;
|
||||
replace(root, h("div", { class: "todo-view" }, ...state.projects.map((p) => projectBlock(p, todos.get(p.id), starting, start))));
|
||||
root.querySelector(".todo-view").scrollTop = scrollTop;
|
||||
};
|
||||
const load = async (projectId) => {
|
||||
try {
|
||||
const todo = await get("/api/projects/{projectId}/todo", { path: { projectId } });
|
||||
todos.set(projectId, todo);
|
||||
}
|
||||
catch (err) {
|
||||
todos.set(projectId, `Couldn't read TODO.md: ${errorText(err)}`);
|
||||
}
|
||||
if (!disposed) {
|
||||
render();
|
||||
}
|
||||
};
|
||||
const refresh = () => {
|
||||
for (const p of state.projects) {
|
||||
void load(p.id);
|
||||
}
|
||||
};
|
||||
const start = async (project, item) => {
|
||||
const key = `${project.id}\n${item.title}`;
|
||||
starting.add(key);
|
||||
render();
|
||||
try {
|
||||
const task = await post("/api/projects/{projectId}/todo/tasks", { path: { projectId: project.id }, body: { title: item.title, model: models[0] } });
|
||||
location.hash = `#/task/${task.id}`;
|
||||
openTranscript();
|
||||
}
|
||||
catch (err) {
|
||||
void showAlert(errorText(err));
|
||||
}
|
||||
starting.delete(key);
|
||||
if (!disposed) {
|
||||
render();
|
||||
}
|
||||
};
|
||||
const offs = [
|
||||
on("event", (detail) => {
|
||||
const ev = detail;
|
||||
if (!refreshKinds.has(ev.kind)) {
|
||||
return;
|
||||
}
|
||||
if (ev.project_id) {
|
||||
void load(ev.project_id);
|
||||
}
|
||||
}),
|
||||
on("connection", () => {
|
||||
if (state.connected) {
|
||||
refresh();
|
||||
}
|
||||
}),
|
||||
on("projects", refresh),
|
||||
onEach(["tasks", "sessions", "selection"], render),
|
||||
];
|
||||
render();
|
||||
refresh();
|
||||
return () => {
|
||||
disposed = true;
|
||||
for (const off of offs) {
|
||||
off();
|
||||
}
|
||||
};
|
||||
}
|
||||
function projectBlock(project, todo, starting, start) {
|
||||
const head = h("h2", {}, project.name, " ", h("span", { class: "repo" }, `TODO.md on ${project.default_branch}`));
|
||||
if (todo === undefined) {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row" }, "Loading…"));
|
||||
}
|
||||
if (typeof todo === "string") {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row error-text" }, todo));
|
||||
}
|
||||
if (!todo.exists) {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row" }, `No TODO.md on ${project.default_branch}.`));
|
||||
}
|
||||
if (todo.items.length === 0) {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row" }, "TODO.md has no items."));
|
||||
}
|
||||
const active = (state.tasks.get(project.id) ?? []).filter((t) => t.status === "active" && t.todo_item);
|
||||
const children = [];
|
||||
let section = "";
|
||||
let list;
|
||||
for (const item of todo.items) {
|
||||
if (!list || item.section !== section) {
|
||||
section = item.section;
|
||||
if (section) {
|
||||
children.push(h("h3", { class: "todo-section" }, section));
|
||||
}
|
||||
list = h("ul", { class: "todo-list" });
|
||||
children.push(list);
|
||||
}
|
||||
const task = active.find((t) => t.todo_item === item.title);
|
||||
let action;
|
||||
if (task) {
|
||||
const sess = currentSession(task.id);
|
||||
action = h("a", { class: "todo-task", href: `#/task/${task.id}`, onclick: openTranscript }, h("span", { class: `dot ${sess?.state ?? "none"}`, title: sess?.state ?? "no session" }), sess?.state ?? "no agent");
|
||||
}
|
||||
else {
|
||||
const busy = starting.has(`${project.id}\n${item.title}`);
|
||||
const button = h("button", { disabled: busy }, busy ? "Starting…" : "Start");
|
||||
button.onclick = () => void start(project, item);
|
||||
action = button;
|
||||
}
|
||||
list.append(h("li", { class: task && task.id === state.selectedTaskId ? "selected" : "" }, h("div", { class: "todo-head" }, h("span", { class: "todo-title" }, item.title), action), item.body && markdown(item.body, "md todo-body")));
|
||||
}
|
||||
return h("section", { class: "project" }, head, ...children);
|
||||
}
|
||||
//# sourceMappingURL=todo.js.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -123,6 +123,44 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/projects/{projectId}/todo": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
projectId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
/** @description The items of TODO.md at the root of the project's default branch, in file order. */
|
||||
get: operations["getTodo"];
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/projects/{projectId}/todo/tasks": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
projectId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/** @description Creates a task for a TODO.md item, recording the item as its todo_item, and starts its agent with the item as the first message. Refused while another active task has the same item. */
|
||||
post: operations["startTodoItem"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/tasks/{taskId}": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -603,6 +641,26 @@ export interface components {
|
||||
closed_at?: string;
|
||||
/** @description merged: the squash commit on the default branch; empty when there was nothing to merge. */
|
||||
merge_commit?: string;
|
||||
/** @description The title of the TODO.md item the task was started from; absent for other tasks. */
|
||||
todo_item?: string;
|
||||
};
|
||||
Todo: {
|
||||
/** @description Whether the default branch has a TODO.md at its root. */
|
||||
exists: boolean;
|
||||
items: components["schemas"]["TodoItem"][];
|
||||
};
|
||||
TodoItem: {
|
||||
/** @description The item's first line, without its list marker: the item's identity. */
|
||||
title: string;
|
||||
/** @description The item's further lines */
|
||||
body: string;
|
||||
/** @description The text of the nearest heading above the item; empty when there is none. */
|
||||
section: string;
|
||||
};
|
||||
TodoStart: {
|
||||
/** @description The title of the item to start. */
|
||||
title: string;
|
||||
model?: string;
|
||||
};
|
||||
Unmerged: {
|
||||
/** @description Commits on the task branch that aren't on the default branch. */
|
||||
@@ -1142,6 +1200,58 @@ export interface operations {
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
getTodo: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
projectId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description The items; exists is false when the default branch has no TODO.md. */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Todo"];
|
||||
};
|
||||
};
|
||||
404: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
startTodoItem: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
projectId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["TodoStart"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description The new task. */
|
||||
201: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Task"];
|
||||
};
|
||||
};
|
||||
400: components["responses"]["Error"];
|
||||
404: components["responses"]["Error"];
|
||||
409: components["responses"]["Error"];
|
||||
};
|
||||
};
|
||||
getTask: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
|
||||
+4
-2
@@ -5,19 +5,21 @@ import { mountInbox } from "./inbox.js";
|
||||
import { mountSettings } from "./settings.js";
|
||||
import { mountTranscript } from "./task.js";
|
||||
import { mountTasks } from "./tasks.js";
|
||||
import { mountTodo } from "./todo.js";
|
||||
|
||||
export type View = "transcript" | "changes" | "tasks" | "inbox" | "admin" | "settings";
|
||||
export type View = "transcript" | "changes" | "tasks" | "todo" | "inbox" | "admin" | "settings";
|
||||
|
||||
const views: Record<View, { label: string; mount: (root: HTMLElement) => () => void }> = {
|
||||
transcript: { label: "Transcript", mount: mountTranscript },
|
||||
changes: { label: "Changes", mount: (root) => mountChanges(root) },
|
||||
tasks: { label: "Tasks", mount: mountTasks },
|
||||
todo: { label: "Todo", mount: mountTodo },
|
||||
inbox: { label: "Inbox", mount: mountInbox },
|
||||
admin: { label: "Admin", mount: mountAdmin },
|
||||
settings: { label: "Settings", mount: mountSettings },
|
||||
};
|
||||
|
||||
const order: View[] = ["transcript", "changes", "tasks", "inbox", "admin", "settings"];
|
||||
const order: View[] = ["transcript", "changes", "tasks", "todo", "inbox", "admin", "settings"];
|
||||
|
||||
const panes: Pane[] = [];
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { markdown } from "./markdown.js";
|
||||
import { openChanges } from "./panes.js";
|
||||
import { currentSession, findTask, onEach, pinSnapshot, state } from "./state.js";
|
||||
|
||||
const models = ["claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-fable-5-1"];
|
||||
export const models = ["claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5", "claude-fable-5-1"];
|
||||
|
||||
type Call = { name: string; target: string };
|
||||
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
import { get, post, type ByreEvent, type Project, type Schemas } from "./api.js";
|
||||
import { errorText, h, replace, showAlert } from "./dom.js";
|
||||
import { markdown } from "./markdown.js";
|
||||
import { openTranscript } from "./panes.js";
|
||||
import { models } from "./task.js";
|
||||
import { currentSession, on, onEach, state } from "./state.js";
|
||||
|
||||
type Todo = Schemas["Todo"];
|
||||
type TodoItem = Schemas["TodoItem"];
|
||||
|
||||
const refreshKinds = new Set(["task.merged", "project.created"]);
|
||||
|
||||
export function mountTodo(root: HTMLElement): () => void {
|
||||
const todos = new Map<string, Todo | string>();
|
||||
const starting = new Set<string>();
|
||||
let disposed = false;
|
||||
|
||||
const render = () => {
|
||||
const scrollTop = root.querySelector(".todo-view")?.scrollTop ?? 0;
|
||||
replace(root, h("div", { class: "todo-view" }, ...state.projects.map((p) => projectBlock(p, todos.get(p.id), starting, start))));
|
||||
root.querySelector(".todo-view")!.scrollTop = scrollTop;
|
||||
};
|
||||
|
||||
const load = async (projectId: string) => {
|
||||
try {
|
||||
const todo = await get("/api/projects/{projectId}/todo", { path: { projectId } });
|
||||
todos.set(projectId, todo);
|
||||
} catch (err) {
|
||||
todos.set(projectId, `Couldn't read TODO.md: ${errorText(err)}`);
|
||||
}
|
||||
if (!disposed) {
|
||||
render();
|
||||
}
|
||||
};
|
||||
|
||||
const refresh = () => {
|
||||
for (const p of state.projects) {
|
||||
void load(p.id);
|
||||
}
|
||||
};
|
||||
|
||||
const start = async (project: Project, item: TodoItem) => {
|
||||
const key = `${project.id}\n${item.title}`;
|
||||
starting.add(key);
|
||||
render();
|
||||
try {
|
||||
const task = await post("/api/projects/{projectId}/todo/tasks", { path: { projectId: project.id }, body: { title: item.title, model: models[0] } });
|
||||
location.hash = `#/task/${task.id}`;
|
||||
openTranscript();
|
||||
} catch (err) {
|
||||
void showAlert(errorText(err));
|
||||
}
|
||||
starting.delete(key);
|
||||
if (!disposed) {
|
||||
render();
|
||||
}
|
||||
};
|
||||
|
||||
const offs = [
|
||||
on("event", (detail?: unknown) => {
|
||||
const ev = detail as ByreEvent;
|
||||
if (!refreshKinds.has(ev.kind)) {
|
||||
return;
|
||||
}
|
||||
if (ev.project_id) {
|
||||
void load(ev.project_id);
|
||||
}
|
||||
}),
|
||||
on("connection", () => {
|
||||
if (state.connected) {
|
||||
refresh();
|
||||
}
|
||||
}),
|
||||
on("projects", refresh),
|
||||
onEach(["tasks", "sessions", "selection"], render),
|
||||
];
|
||||
|
||||
render();
|
||||
refresh();
|
||||
|
||||
return () => {
|
||||
disposed = true;
|
||||
for (const off of offs) {
|
||||
off();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function projectBlock(project: Project, todo: Todo | string | undefined, starting: Set<string>, start: (p: Project, item: TodoItem) => Promise<void>): HTMLElement {
|
||||
const head = h("h2", {}, project.name, " ", h("span", { class: "repo" }, `TODO.md on ${project.default_branch}`));
|
||||
|
||||
if (todo === undefined) {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row" }, "Loading…"));
|
||||
}
|
||||
if (typeof todo === "string") {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row error-text" }, todo));
|
||||
}
|
||||
if (!todo.exists) {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row" }, `No TODO.md on ${project.default_branch}.`));
|
||||
}
|
||||
if (todo.items.length === 0) {
|
||||
return h("section", { class: "project" }, head, h("p", { class: "empty-row" }, "TODO.md has no items."));
|
||||
}
|
||||
|
||||
const active = (state.tasks.get(project.id) ?? []).filter((t) => t.status === "active" && t.todo_item);
|
||||
const children: HTMLElement[] = [];
|
||||
let section = "";
|
||||
let list: HTMLElement | undefined;
|
||||
for (const item of todo.items) {
|
||||
if (!list || item.section !== section) {
|
||||
section = item.section;
|
||||
if (section) {
|
||||
children.push(h("h3", { class: "todo-section" }, section));
|
||||
}
|
||||
list = h("ul", { class: "todo-list" });
|
||||
children.push(list);
|
||||
}
|
||||
|
||||
const task = active.find((t) => t.todo_item === item.title);
|
||||
let action: HTMLElement;
|
||||
if (task) {
|
||||
const sess = currentSession(task.id);
|
||||
action = h(
|
||||
"a",
|
||||
{ class: "todo-task", href: `#/task/${task.id}`, onclick: openTranscript },
|
||||
h("span", { class: `dot ${sess?.state ?? "none"}`, title: sess?.state ?? "no session" }),
|
||||
sess?.state ?? "no agent",
|
||||
);
|
||||
} else {
|
||||
const busy = starting.has(`${project.id}\n${item.title}`);
|
||||
const button = h("button", { disabled: busy }, busy ? "Starting…" : "Start");
|
||||
button.onclick = () => void start(project, item);
|
||||
action = button;
|
||||
}
|
||||
|
||||
list.append(
|
||||
h(
|
||||
"li",
|
||||
{ class: task && task.id === state.selectedTaskId ? "selected" : "" },
|
||||
h("div", { class: "todo-head" }, h("span", { class: "todo-title" }, item.title), action),
|
||||
item.body && markdown(item.body, "md todo-body"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return h("section", { class: "project" }, head, ...children);
|
||||
}
|
||||
@@ -327,6 +327,61 @@ textarea {
|
||||
padding: 8px 16px 16px;
|
||||
}
|
||||
|
||||
.todo-view {
|
||||
overflow-y: auto;
|
||||
padding: 8px 16px 16px;
|
||||
}
|
||||
|
||||
.todo-section {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
margin: 10px 0 4px;
|
||||
}
|
||||
|
||||
.todo-list {
|
||||
list-style: none;
|
||||
margin: 0 0 8px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.todo-list li {
|
||||
padding: 6px 10px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.todo-list li.selected {
|
||||
background: var(--accent-tint);
|
||||
}
|
||||
|
||||
.todo-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.todo-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.todo-task {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.todo-head button {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.todo-body {
|
||||
color: var(--muted);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.project h2 {
|
||||
font-size: 13px;
|
||||
margin: 16px 0 6px;
|
||||
|
||||
Reference in New Issue
Block a user