Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 127 additions & 112 deletions styles/components/issues/editor.ts
Original file line number Diff line number Diff line change
@@ -1,129 +1,144 @@
import { otherThemeVars, themeVars } from "@lutinglt/gitea-github-theme/core";
import { css, otherThemeVars, themeVars } from "@lutinglt/gitea-github-theme/core";

/** GitHub's comment editor, for the rules of a `.combo-markdown-editor`: a bordered box whose toolbar carries the Write/Preview tabs. */
export const markdownEditor = `
border: 1px solid ${themeVars.color.light.border};
border-radius: ${otherThemeVars.border.radius};
background: ${themeVars.color.body};
& markdown-toolbar {
background: ${themeVars.color.box.header};
border-bottom: 1px solid ${themeVars.color.light.border};
}
& .markdown-toolbar-button {
color: ${themeVars.color.text.light.num1};
width: 28px;
height: 28px;
padding: 6px;
border: 0;
background: transparent;
}
& textarea {
background: ${themeVars.color.body};
font-size: 14px;
/**
* GitHub's comment editor, written once for every place Forgejo renders its markdown editor in an
* issue or pull request: a bordered box whose toolbar carries the Write/Preview tabs, and a plain
* attachment line instead of a dashed drop area. To style another editor, add its container here.
*/
const hosts = `:is(
.page-content.repository.view.issue.github-conversation .comment.form,
.page-content.repository.new.issue.github-issue-new,
.review-box-panel,
.comment-code-cloud
)`;

export default css`
${hosts} .combo-markdown-editor {
border: 1px solid ${themeVars.color.light.border};
border-radius: ${otherThemeVars.border.radius};
box-shadow: none;
}
overflow: visible;

& markdown-toolbar {
border-radius: ${otherThemeVars.border.radius} ${otherThemeVars.border.radius} 0 0;
min-height: 38px;
padding: 0 8px 0 0;
gap: 8px;

& .markdown-toolbar-group {
flex: 0 0 auto;
background: ${themeVars.color.body};
& markdown-toolbar {
background: ${themeVars.color.box.header};
border-bottom: 1px solid ${themeVars.color.light.border};
}
& .switch {
& .markdown-toolbar-button {
color: ${themeVars.color.text.light.num1};
width: 28px;
height: 28px;
padding: 6px;
border: 0;
background: transparent;
border-radius: 0;
margin: 0 auto -1px 0;
min-height: 38px;
}
/* Forgejo overlaps neighbouring switch items with negative margins and paints the first one. */
& .switch .item {
height: 38px;
min-height: 38px;
margin: 0 !important;
padding: 8px 16px !important;
border: 1px solid transparent;
border-radius: 0;
background: transparent !important;
box-shadow: none;
outline: 0;
color: ${themeVars.color.text.light.num1};
& textarea {
background: ${themeVars.color.body};
font-size: 14px;
line-height: 21px;
font-weight: 400;
}
& .switch .item:not(.active):hover {
color: ${themeVars.color.text.self};
}
& .switch .item.active {
border-right-color: ${themeVars.color.light.border};
border-left-color: ${themeVars.color.light.border};
border-bottom-color: ${themeVars.color.body};
background: ${themeVars.color.body} !important;
color: ${themeVars.color.text.self};
border: 1px solid ${themeVars.color.light.border};
border-radius: ${otherThemeVars.border.radius};
box-shadow: none;
}
/* The editor's own border already draws the first tab's left edge. */
& .switch .item.active:first-child {
border-left-color: transparent;
border-top-left-radius: ${otherThemeVars.border.radius};
overflow: visible;

& markdown-toolbar {
border-radius: ${otherThemeVars.border.radius} ${otherThemeVars.border.radius} 0 0;
min-height: 38px;
padding: 0 8px 0 0;
gap: 8px;

& .markdown-toolbar-group {
flex: 0 0 auto;
}
& .switch {
border: 0;
background: transparent;
border-radius: 0;
margin: 0 auto -1px 0;
min-height: 38px;
}
/* Forgejo overlaps neighbouring switch items with negative margins and paints the first one. */
& .switch .item {
height: 38px;
min-height: 38px;
margin: 0 !important;
padding: 8px 16px !important;
border: 1px solid transparent;
border-radius: 0;
background: transparent !important;
box-shadow: none;
outline: 0;
color: ${themeVars.color.text.light.num1};
font-size: 14px;
line-height: 21px;
font-weight: 400;
}
& .switch .item:not(.active):hover {
color: ${themeVars.color.text.self};
}
& .switch .item.active {
border-right-color: ${themeVars.color.light.border};
border-left-color: ${themeVars.color.light.border};
border-bottom-color: ${themeVars.color.body};
background: ${themeVars.color.body} !important;
color: ${themeVars.color.text.self};
}
/* The editor's own border already draws the first tab's left edge. */
& .switch .item.active:first-child {
border-left-color: transparent;
border-top-left-radius: ${otherThemeVars.border.radius};
}
& .switch .item:focus-visible {
outline: 2px solid ${themeVars.github.fgColor.accent};
outline-offset: -2px;
}
& .switch .item.active::before,
& .switch .item.active::after {
display: none;
}
}
& .switch .item:focus-visible {
outline: 2px solid ${themeVars.github.fgColor.accent};
outline-offset: -2px;
& > .ui.tab.markup {
background: ${themeVars.color.body};
padding: 16px;
min-height: 136px;
font-size: 14px;
line-height: 21px;
}
& .switch .item.active::before,
& .switch .item.active::after {
display: none;
& textarea {
margin: 8px;
width: calc(100% - 16px);
height: auto;
min-height: 123px;
max-height: calc(35lh + 18px);
field-sizing: content;
line-height: 21px;
font-family: var(--fonts-proportional);
padding: 8px;
}
}
& > .ui.tab.markup {
background: ${themeVars.color.body};
padding: 16px;
min-height: 136px;
font-size: 14px;
line-height: 21px;
}
& textarea {
margin: 8px;
width: calc(100% - 16px);
height: auto;
min-height: 123px;
max-height: calc(35lh + 18px);
field-sizing: content;
line-height: 21px;
font-family: var(--fonts-proportional);
padding: 8px;
}
`;

/** The attachment line under an editor, for the rules of its `.dropzone`: a plain text button instead of a dashed drop area. */
export const attachmentDropzone = `
min-height: 32px;
padding: 0;
border: 0;
background: transparent;
& .dz-message {
margin: 0;
text-align: left;
}
& .dz-button {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 6px 8px;
${hosts} .ui.dropzone {
min-height: 32px;
font-size: 12px;
line-height: 18px;
font-weight: 400;
color: ${themeVars.color.text.light.num1};
background: transparent;
padding: 0;
border: 0;
box-shadow: none;
background: transparent;
& .dz-message {
margin: 0;
text-align: left;
}
& .dz-button {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 6px 8px;
min-height: 32px;
font-size: 12px;
line-height: 18px;
font-weight: 400;
color: ${themeVars.color.text.light.num1};
background: transparent;
border: 0;
box-shadow: none;
}
border: 0 !important;
& .dz-button {
color: ${themeVars.color.text.light.num1} !important;
}
}
`;
4 changes: 4 additions & 0 deletions styles/components/issues/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/

import { cssCombine } from "@lutinglt/gitea-github-theme/core";
import editor from "./editor";
import issue from "./issue";
import issueComment from "./issue_comment";
import issueConversation from "./issue_conversation";
import issueList from "./issue_list";
import issueNew from "./issue_new";
import issueOverview from "./issue_overview";
import issueSidebar from "./issue_sidebar";
import issueTimeline from "./issue_timeline";
Expand All @@ -34,6 +36,8 @@ export default cssCombine(
issueList,
issueOverview,
issueConversation,
editor,
issueNew,
pullReview,
pullFilesReview,
issueSidebar,
Expand Down
8 changes: 1 addition & 7 deletions styles/components/issues/issue_conversation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { css, otherThemeVars, themeVars } from "@lutinglt/gitea-github-theme/core";
import { attachmentDropzone, markdownEditor } from "./editor";

export default css`
.page-content.repository.view.issue.github-conversation {
Expand Down Expand Up @@ -39,6 +38,7 @@ export default css`
align-items: center;
gap: 4px;
font-size: 14px;
font-weight: 600;
line-height: 20px;
border-radius: 20px !important;
}
Expand Down Expand Up @@ -471,12 +471,6 @@ export default css`
color: ${themeVars.github.borderColor.done.emphasis};
}
}
& .combo-markdown-editor {
${markdownEditor}
}
& .dropzone {
${attachmentDropzone}
}
}

&.own-conversation .comment.first {
Expand Down
Loading
Loading