Skip to content

Commit

Permalink
Merge branch 'T3sT3ro-beta' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Nov 28, 2024
2 parents 2f76de2 + 231bd89 commit f38144b
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 27 deletions.
1 change: 1 addition & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@
"panel.seoKeywords.density": "Keyword density",
"panel.seoKeywordInfo.validInfo.label": "Heading(s)",
"panel.seoKeywordInfo.validInfo.content": "Content",
"panel.seoKeywordInfo.density.tooltip": "Recommended frequency: 0.75% - 1.5%",

"panel.seoKeywords.title": "Keywords",
"panel.seoKeywords.header.keyword": "Keyword",
Expand Down
26 changes: 26 additions & 0 deletions src/components/common/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import { Tooltip as TT } from 'react-tooltip'

export interface ITooltipProps {
id: string;
render?: () => React.ReactNode;
}

export const Tooltip: React.FunctionComponent<ITooltipProps> = ({
id,
render
}: React.PropsWithChildren<ITooltipProps>) => {

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`;

return (
<TT
id={id}
className={tooltipClasses}
style={{
fontSize: '12px',
lineHeight: '19px'
}}
render={render} />
);
};
6 changes: 5 additions & 1 deletion src/localization/localization.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export enum LocalizationKey {
*/
dashboardHeaderPaginationPrevious = 'dashboard.header.pagination.previous',
/**
* next
* Next
*/
dashboardHeaderPaginationNext = 'dashboard.header.pagination.next',
/**
Expand Down Expand Up @@ -1620,6 +1620,10 @@ export enum LocalizationKey {
* Content
*/
panelSeoKeywordInfoValidInfoContent = 'panel.seoKeywordInfo.validInfo.content',
/**
* Recommended frequency: 0.75% - 1.5%
*/
panelSeoKeywordInfoDensityTooltip = 'panel.seoKeywordInfo.density.tooltip',
/**
* Keywords
*/
Expand Down
38 changes: 19 additions & 19 deletions src/panelWebView/components/SeoKeywordInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Tag } from './Tag';
import { LocalizationKey, localize } from '../../localization';
import { Messenger } from '@estruyf/vscode/dist/client';
import { CommandToCode } from '../CommandToCode';
import { Tooltip } from 'react-tooltip'
import { Tooltip } from '../../components/common/Tooltip';

export interface ISeoKeywordInfoProps {
keywords: string[];
Expand All @@ -29,8 +29,6 @@ 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)] text-left`;

const density = () => {
if (!wordCount) {
return null;
Expand All @@ -40,14 +38,15 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
const count = (content.match(pattern) || []).length;
const density = (count / wordCount) * 100;
const densityTitle = `${density.toFixed(2)}* %`;

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-[var(--vscode-charts-green)]'>{densityTitle}</span>;
} else {
return <span className='text-[12px] text-[var(--vscode-statusBarItem-warningBackground)]'>{densityTitle}</span>;
}
const color = (density >= 0.75 && density < 1.5) ? "--vscode-charts-green" : "--vscode-charts-yellow";
return (
<span
className={`text-[12px] text-[var(${color})] cursor-default`}
data-tooltip-id={`tooltip-density-${keyword}`}
data-tooltip-content={localize(LocalizationKey.panelSeoKeywordInfoDensityTooltip)}>
{densityTitle}
</span>
);
};

const validateKeywords = (heading: string, keyword: string) => {
Expand Down Expand Up @@ -98,7 +97,7 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
const tooltipContent = React.useMemo(() => {
return (
<>
<b>Keyword present in:</b><br />
<h4>Keyword present in:</h4>
<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 />
Expand All @@ -116,7 +115,10 @@ 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-[--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]"}`}
className={`inline-flex py-0.5 px-2 my-1 rounded-[3px] justify-center items-center text-[12px] leading-[16px] border border-solid cursor-default
${isValid
? "text-[var(--vscode-charts-green)] border-[var(--vscode-charts-green)] bg-[var(--frontmatter-success-background)]"
: "text-[var(--vscode-charts-yellow)] border-[var(--vscode-charts-yellow)] bg-[var(--frontmatter-warning-background)]"}`}
data-tooltip-id={`tooltip-checks-${keyword}`}
>
<ValidInfo isValid={isValid} />
Expand All @@ -137,7 +139,7 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
<div className='flex h-full items-center'>
<Tag
value={keyword}
className={`!w-full !justify-between !mx-0 !my-1 !px-2 !py-1`}
className={`!w-full !justify-between !mx-0 !my-1 !px-2 !py-0.5`}
onRemove={onRemove}
onCreate={() => void 0}
title={localize(LocalizationKey.panelTagsTagWarning, keyword)}
Expand All @@ -150,15 +152,13 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({

<Tooltip
id={`tooltip-checks-${keyword}`}
className={tooltipClasses}
style={{
fontSize: '12px',
lineHeight: '19px'
}}
render={() => tooltipContent} />
</VSCodeTableCell>
<VSCodeTableCell className={`text-center`}>
{density()}

<Tooltip
id={`tooltip-density-${keyword}`} />
</VSCodeTableCell>
</VSCodeTableRow>
);
Expand Down
2 changes: 1 addition & 1 deletion src/panelWebView/components/VSCode/VSCodeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const VSCodeTableHead = React.forwardRef<
<th
ref={ref}
className={cn(
"h-6 px-2 py-2 text-left align-middle font-bold",
"h-6 px-2 py-2 text-left align-middle font-bold cursor-default",
className
)}
{...props}
Expand Down
6 changes: 3 additions & 3 deletions src/panelWebView/components/ValidInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const ValidInfo: React.FunctionComponent<IValidInfoProps> = ({
return (
<div className='inline-flex items-center h-full'>
{isValid ? (
<CheckIcon className={`h-4 w-4 text-[var(--vscode-charts-green)] mr-2`} />
<CheckIcon className={`h-6 w-6 text-[var(--vscode-charts-green)] mr-2`} />
) : (
<ExclamationTriangleIcon className={`h-4 w-4 text-[var(--vscode-statusBarItem-warningBackground)] mr-2`} />
<ExclamationTriangleIcon className={`h-6 w-6 text-[var(--vscode-charts-yellow)] mr-2`} />
)}
{label && <span className={className || ""}>{label}</span>}
{label && <span className={className || ""}><b>{label}</b></span>}
</div>
);
};
Expand Down
22 changes: 19 additions & 3 deletions src/panelWebView/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -895,14 +895,29 @@ vscode-divider {
color: var(--vscode-inputValidation-infoForeground, #fff);
}

.tag {
transition: all 100ms;
}

.tag:has(.tag__delete:hover) {
background-color: var(--vscode-inputValidation-errorBackground);
color: var(--vscode-inputValidation-errorForeground);
}

.tag .tag__delete {
margin-left: 0.25rem;

& svg {
stroke-width: 3;
}
}

.tag .tag__delete:hover {
background-color: var(--vscode-inputValidation-errorBackground);
color: var(--vscode-inputValidation-errorForeground, #000);
border-radius: 2px;

& svg {
color: var(--vscode-charts-red);
}
}

.vscode-dark .tag .tag__delete:hover {
Expand All @@ -911,7 +926,8 @@ vscode-divider {

.tag .tag__value {
flex-grow: 1;
white-space: nowrap;
white-space: pre-wrap;
font-weight: 600;
}

/* Slug field */
Expand Down

0 comments on commit f38144b

Please sign in to comment.