Skip to content

Commit

Permalink
#705 - Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Nov 25, 2024
1 parent c02275d commit 42fe1c2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@
"panel.seoKeywords.checks": "Checks",
"panel.seoKeywords.density.tableTitle": "Frequency",
"panel.seoKeywords.density": "Keyword density",
"panel.seoKeywordInfo.validInfo.label": "Used in heading(s)",
"panel.seoKeywordInfo.validInfo.label": "Heading(s)",
"panel.seoKeywordInfo.validInfo.content": "Content",

"panel.seoKeywords.title": "Keywords",
Expand Down
13 changes: 13 additions & 0 deletions src/dashboardWebView/utils/updateCssVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,17 @@ export const updateCssVariables = (isDarkTheme = true) => {
'--frontmatter-border-active',
darkenColor(borderColor, isDarkTheme ? -30 : 30) || 'var(--vscode-activityBar-activeBorder)'
);

// SEO - Success/Warning colors
const successColor = styles.getPropertyValue('--vscode-charts-green');
document.documentElement.style.setProperty(
'--frontmatter-success-background',
opacityColor(successColor, 0.05) || 'var(--vscode-charts-green)'
);

const warningColor = styles.getPropertyValue('--vscode-statusBarItem-warningBackground');
document.documentElement.style.setProperty(
'--frontmatter-warning-background',
opacityColor(warningColor, 0.05) || 'var(--vscode-statusBarItem-warningBackground)'
);
};
17 changes: 9 additions & 8 deletions src/panelWebView/components/SeoKeywordInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
headings
}: React.PropsWithChildren<ISeoKeywordInfoProps>) => {

const tooltipClasses = `!py-[2px] !px-[8px] !rounded-[3px] !border-[var(--vscode-editorHoverWidget-border)] !border !border-solid !bg-[var(--vscode-editorHoverWidget-background)] !text-[var(--vscode-editorHoverWidget-foreground)] !font-normal !opacity-100 shadow-[0_2px_8px_var(--vscode-widget-shadow)] !z-[9999]`;
const tooltipClasses = `!py-[2px] !px-[8px] !rounded-[3px] !border-[var(--vscode-editorHoverWidget-border)] !border !border-solid !bg-[var(--vscode-editorHoverWidget-background)] !text-[var(--vscode-editorHoverWidget-foreground)] !font-normal !opacity-100 shadow-[0_2px_8px_var(--vscode-widget-shadow)] text-left`;

const density = () => {
if (!wordCount) {
Expand All @@ -44,7 +44,7 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
if (density < 0.75) {
return <span className='text-[12px] text-[var(--vscode-statusBarItem-warningBackground)]'>{densityTitle}</span>;
} else if (density >= 0.75 && density < 1.5) {
return <span className='text-[12px] text-[#1f883d]'>{densityTitle}</span>;
return <span className='text-[12px] text-[var(--vscode-charts-green)]'>{densityTitle}</span>;
} else {
return <span className='text-[12px] text-[var(--vscode-statusBarItem-warningBackground)]'>{densityTitle}</span>;
}
Expand Down Expand Up @@ -98,11 +98,12 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
const tooltipContent = React.useMemo(() => {
return (
<>
<span className='inline-flex items-center gap-1'>{localize(LocalizationKey.commonTitle)}: <ValidInfo isValid={checks.title} /></span><br />
<span className='inline-flex items-center gap-1'>{localize(LocalizationKey.commonDescription)}: <ValidInfo isValid={checks.description} /></span><br />
<span className='inline-flex items-center gap-1'>{localize(LocalizationKey.commonSlug)}: <ValidInfo isValid={checks.slug} /></span><br />
<span className='inline-flex items-center gap-1'>{localize(LocalizationKey.panelSeoKeywordInfoValidInfoContent)}: <ValidInfo isValid={checks.content} /></span><br />
<span className='inline-flex items-center gap-1'>{localize(LocalizationKey.panelSeoKeywordInfoValidInfoLabel)}: <ValidInfo isValid={!!checks.heading} /></span>
<b>Keyword present in:</b><br />
<span className='inline-flex items-center gap-1'><ValidInfo isValid={checks.title} /> {localize(LocalizationKey.commonTitle)}</span><br />
<span className='inline-flex items-center gap-1'><ValidInfo isValid={checks.description} /> {localize(LocalizationKey.commonDescription)}</span><br />
<span className='inline-flex items-center gap-1'><ValidInfo isValid={checks.slug} /> {localize(LocalizationKey.commonSlug)}</span><br />
<span className='inline-flex items-center gap-1'><ValidInfo isValid={checks.content} /> {localize(LocalizationKey.panelSeoKeywordInfoValidInfoContent)}</span><br />
<span className='inline-flex items-center gap-1'><ValidInfo isValid={!!checks.heading} /> {localize(LocalizationKey.panelSeoKeywordInfoValidInfoLabel)}</span>
</>
)
}, [checks]);
Expand All @@ -115,7 +116,7 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({

return (
<div
className={`inline-flex py-1 px-[4px] rounded-[3px] justify-center items-center text-[12px] leading-[16px] border border-solid ${isValid ? "text-[#1f883d] border-[#1f883d]" : "text-[var(--vscode-statusBarItem-warningBackground)] border-[var(--vscode-statusBarItem-warningBackground)]"}`}
className={`inline-flex py-1 px-[4px] rounded-[3px] justify-center items-center text-[12px] leading-[16px] border border-solid ${isValid ? "text-[--vscode-charts-green] border-[--vscode-charts-green] bg-[--frontmatter-success-background]" : "text-[var(--vscode-statusBarItem-warningBackground)] border-[var(--vscode-statusBarItem-warningBackground)] bg-[--frontmatter-warning-background]"}`}
data-tooltip-id={`tooltip-checks-${keyword}`}
>
<ValidInfo isValid={isValid} />
Expand Down
4 changes: 2 additions & 2 deletions src/panelWebView/components/SeoKeywords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ const SeoKeywords: React.FunctionComponent<ISeoKeywordsProps> = ({
<VSCodeTableHead>
{localize(LocalizationKey.panelSeoKeywordsHeaderKeyword)}
</VSCodeTableHead>
<VSCodeTableHead>
<VSCodeTableHead className={`text-center`}>
{localize(LocalizationKey.panelSeoKeywordsChecks)}
</VSCodeTableHead>

<VSCodeTableHead>
<VSCodeTableHead className={`text-center`}>
<span
data-tooltip-id="tooltip-density"
data-tooltip-content={localize(LocalizationKey.panelSeoKeywordsDensity)}>
Expand Down
2 changes: 1 addition & 1 deletion src/panelWebView/components/ValidInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ValidInfo: React.FunctionComponent<IValidInfoProps> = ({
return (
<div className='inline-flex items-center h-full'>
{isValid ? (
<CheckIcon className={`h-4 w-4 text-[#1f883d] mr-2`} />
<CheckIcon className={`h-4 w-4 text-[var(--vscode-charts-green)] mr-2`} />
) : (
<ExclamationTriangleIcon className={`h-4 w-4 text-[var(--vscode-statusBarItem-warningBackground)] mr-2`} />
)}
Expand Down
9 changes: 9 additions & 0 deletions src/panelWebView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { ViewPanel } from './ViewPanel';
import { RecoilRoot } from 'recoil';
import { I10nProvider } from '../dashboardWebView/providers/I10nProvider';
import { SentryInit } from '../utils/sentryInit';
import { updateCssVariables } from '../dashboardWebView/utils/updateCssVariables';
import 'vscrui/dist/codicon.css';

import './styles.css';

const mutationObserver = new MutationObserver((_, __) => {
const darkMode = document.body.classList.contains('vscode-dark');
updateCssVariables(darkMode);
});

// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare const acquireVsCodeApi: <T = unknown>() => {
getState: () => T;
Expand All @@ -24,6 +30,9 @@ if (elm) {
const isProd = elm?.getAttribute('data-isProd');
const isCrashDisabled = elm?.getAttribute('data-is-crash-disabled');

updateCssVariables(document.body.classList.contains('vscode-dark'));
mutationObserver.observe(document.body, { childList: false, attributes: true });

if (isProd === 'true' && isCrashDisabled === 'false') {
Sentry.init(SentryInit(version, environment));

Expand Down

0 comments on commit 42fe1c2

Please sign in to comment.