Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[FEATURE] Add 'show city name' setting to the Weather plugin #615

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/plugins/widgets/weather/Weather.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
.summary
cursor: pointer

i:first-child
margin-left: 0

i
margin: 0 0.5em

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/widgets/weather/Weather.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Weather: React.FC<Props> = ({
onClick={() => setData({ ...data, showDetails: !data.showDetails })}
title="Toggle weather details"
>
{data.name ? <span>{data.name}</span> : null}
{data.name && data.showCity ? <span>{data.name}</span> : null}
<Icon name={weatherCodes[conditions.weatherCode]} />
<span className="temperature">
{Math.round(conditions.temperature)}˚
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/widgets/weather/WeatherSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ const WeatherSettings: FC<Props> = ({ data = defaultData, setData }) => (
Show extended details
</label>

<label>
<input
type="checkbox"
checked={data.showCity}
onChange={() =>
setData({ ...data, showCity: !data.showCity })
}
/>{" "}
Show city name
</label>


<label>
<input
type="radio"
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/widgets/weather/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Coordinates = {
export type Data = Coordinates & {
name?: string;
showDetails: boolean;
showCity: boolean;
units: "auto" | "si" | "us"; // `auto` has been removed, but may still be present in settings
};

Expand All @@ -23,5 +24,6 @@ export type Props = API<Data, Cache>;

export const defaultData: Data = {
showDetails: false,
showCity: true,
units: "si",
};