Skip to content

Commit

Permalink
Merge pull request #184 from sametcodes/develop
Browse files Browse the repository at this point in the history
refactor: updated view function of wakatime:getTimeWithRange
  • Loading branch information
sametcodes authored Apr 24, 2023
2 parents 6f65eca + 58a337e commit 8c13605
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/@dsvgui/components/fallback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Fallback: React.FC<IFallback> = ({ title, message }) => {

const subtitle = wrapText(
message,
{ maxLineWidth: width - 50, fontSize: 14 },
{ maxLineWidth: width - 60, fontSize: 14, fontWeight: 400 },
(line, index) => (
<tspan key={index} x="67" y={index * 16 + 40}>
{line}
Expand Down
2 changes: 1 addition & 1 deletion lib/@dsvgui/components/line/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Document } from "@/lib/@dsvgui";
import { getTextWidth, hexToRgb } from "@/lib/@dsvgui/utils/index";

type ILineItem = {
export type ILineItem = {
leftTitle?: string;
leftSubtitle?: string;
rightTitle?: string;
Expand Down
16 changes: 11 additions & 5 deletions platforms/wakatime/view/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ViewComponent } from "@/platforms/types";
import { SiWakatime } from "react-icons/si";
import { Metrics, Line, BarStats, IBarStats } from "@/lib/@dsvgui";
import { Metrics, Line, BarStats, IBarStats, ILineItem } from "@/lib/@dsvgui";

export const getAllTimeSinceToday: ViewComponent = (result, config) => {
return (
Expand All @@ -12,15 +12,21 @@ export const getAllTimeSinceToday: ViewComponent = (result, config) => {
};

export const getTimeWithRange: ViewComponent = (result, config) => {
const subtitle = (config.queryConfig as any).range;
const { viewConfig, queryConfig } = config as any;
const points = result.data.map((day: any) => day.grand_total.total_seconds);

const lines = [
{
leftTitle: "Line",
leftSubtitle: subtitle,
points,
leftTitle: "WakaTime",
leftSubtitle: "from pulses",
rightTitle: result.cumulative_total.text,
rightSubtitle: queryConfig.range,
points,
period:
viewConfig.showPeriod === false
? undefined
: ("day" as ILineItem["period"]),
lineColor: viewConfig.lineColor,
},
];
return <Line items={lines} />;
Expand Down
17 changes: 15 additions & 2 deletions platforms/wakatime/view/validations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { object, number, string } from "yup";
import { object, number, string, boolean } from "yup";

export const getAllTimeSinceToday = object().required().noUnknown(true);

export const getTimeWithRange = object().required().noUnknown(true);
export const getTimeWithRange = object({
lineColor: string().required().default("#000000").meta({
label: "Line Color",
placeholder: "Line Color",
description: "The color of the line.",
}),
showPeriod: boolean().required().meta({
label: "Show Period",
placeholder: "Show Period",
description: "Whether to show the period or not.",
}),
})
.required()
.noUnknown(true);

export const getMostUsedLanguages = object({
language_count: number().min(1).max(10).default(6).required().meta({
Expand Down

2 comments on commit 8c13605

@vercel
Copy link

@vercel vercel bot commented on 8c13605 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

readmerocks – ./

www.readme.rocks
readmerocks-git-main-sametcodes.vercel.app
readmerocks-sametcodes.vercel.app
readme.rocks

@vercel
Copy link

@vercel vercel bot commented on 8c13605 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

dsvgui – ./lib/@dsvgui

dsvgui.readme.rocks
dsvgui-git-main-sametcodes.vercel.app
dsvgui-sametcodes.vercel.app

Please sign in to comment.