Skip to content

fix(ui): implement dark mode support for reaction buttons #1323

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Apr 29, 2025
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
16 changes: 9 additions & 7 deletions ui/src/pages/Questions/Detail/components/Reactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import classNames from 'classnames';
import { Icon } from '@/components';
import { queryReactions, updateReaction } from '@/services';
import { tryNormalLogged } from '@/utils/guard';
import { isDarkTheme } from '@/utils/common';
import { ReactionItem } from '@/common/interface';

interface Props {
Expand Down Expand Up @@ -60,6 +61,7 @@ const Index: FC<Props> = ({
const [reactions, setReactions] = useState<ReactionItem[]>();
const [reactIsActive, setReactIsActive] = useState<boolean>(false);
const { t } = useTranslation('translation');
const darkMode = isDarkTheme();

useEffect(() => {
queryReactions(objectId).then((res) => {
Expand Down Expand Up @@ -94,7 +96,7 @@ const Index: FC<Props> = ({
: t(`reaction.${d.name}`)
}
key={d.icon}
variant="light"
variant={darkMode ? 'dark' : 'light'}
active={reactions?.find((v) => v.emoji === d.name)?.is_active}
className={`${index !== 0 ? 'ms-1' : ''}`}
size="sm"
Expand All @@ -115,8 +117,8 @@ const Index: FC<Props> = ({
})}>
{showAddCommentBtn && (
<Button
className="rounded-pill me-2 link-secondary"
variant="light"
className="rounded-pill me-2 link-secondary btn-reaction"
variant={darkMode ? 'dark' : 'light'}
size="sm"
onClick={handleClickComment}>
<Icon name="chat-text-fill" />
Expand All @@ -135,8 +137,8 @@ const Index: FC<Props> = ({
aria-label={t('reaction.btn_label')}
aria-haspopup="true"
active={reactIsActive}
className="smile-btn rounded-pill link-secondary"
variant="light">
className="smile-btn rounded-pill link-secondary btn-reaction"
variant={darkMode ? 'dark' : 'light'}>
<Icon name="emoji-smile-fill" />
<span className="ms-1">+</span>
</Button>
Expand All @@ -158,14 +160,14 @@ const Index: FC<Props> = ({
</Tooltip>
}>
<Button
className="rounded-pill ms-2 link-secondary d-flex align-items-center"
className="rounded-pill ms-2 link-secondary d-flex align-items-center btn-reaction"
aria-label={
data?.is_active
? t('reaction.unreact_emoji', { emoji: data.emoji })
: t('reaction.react_emoji', { emoji: data.emoji })
}
aria-pressed="true"
variant="light"
variant={darkMode ? 'dark' : 'light'}
active={data.is_active}
size="sm"
onClick={() =>
Expand Down
23 changes: 21 additions & 2 deletions ui/src/pages/Questions/Detail/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,35 @@
[data-bs-theme='dark'] & {
background-color: var(--bs-gray-800);
}

background-color: var(--bs-gray-100);
}

&:active, &.active {
&:active,
&.active {
background-color: var(--bs-gray-200);

[data-bs-theme='dark'] & {
background-color: var(--bs-gray-700);
}
}
}
}
}

.btn-reaction {
[data-bs-theme='dark'] & {
color: var(--bs-gray-400) !important;
background-color: var(--bs-gray-800);
&:active, &.active {
background-color: #626E79 !important;
}
&:hover {
background-color: #57616B !important;
}
}
}

.answer-item {
border-top: 1px solid var(--an-answer-item-border-top);
}
Expand All @@ -59,4 +78,4 @@
font-size: calc(1.275rem + 0.3vw) !important;
}
}
}
}