Skip to content

Commit

Permalink
Merge pull request #1661 from Shopify/envex/remove-negative-gradient
Browse files Browse the repository at this point in the history
Removed different gradient origins
  • Loading branch information
envex authored Apr 23, 2024
2 parents a1f5197 + 043efab commit 7c8c3c9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,24 @@ import {uniqueId} from '../../../../utilities';
import {LinearGradientWithStops} from '../../../../components';
import {usePolarisVizContext} from '../../../../hooks';

import {getGradientDetails} from './utilities/getGradientDetails';
const GRADIENT_ALPHA = 0.25;

export interface Props {
series: LineChartDataSeriesWithDefaults;
areaPath: SpringValue<string | null> | string;
}

export function DefaultArea({series, areaPath}: Props) {
export function DefaultArea({series: {areaColor}, areaPath}: Props) {
const gradientId = useMemo(() => uniqueId('default-area-gradient'), []);
const maskId = useMemo(() => uniqueId('default-area-mask'), []);
const {data, areaColor} = series;

const {
components: {Path, Defs, Mask},
animated,
} = usePolarisVizContext();

const AnimatedPath = animated(Path);

const gradientStops = useMemo(() => {
return getGradientDetails(data).map((gradientStop) => ({
...gradientStop,
color: areaColor as string,
}));
}, [areaColor, data]);

if (areaPath == null || areaColor == null || gradientStops == null) {
if (areaPath == null || areaColor == null) {
return null;
}

Expand Down Expand Up @@ -73,7 +64,10 @@ export function DefaultArea({series, areaPath}: Props) {
x2="0%"
y1="0%"
y2="100%"
gradient={gradientStops}
gradient={[
{offset: 0, stopOpacity: GRADIENT_ALPHA, color: areaColor},
{offset: 100, stopOpacity: 0, color: areaColor},
]}
/>
</Defs>

Expand Down

This file was deleted.

This file was deleted.

6 changes: 5 additions & 1 deletion packages/polaris-viz/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- ## Unreleased -->
## Unreleased

### Removed

- Removed different gradient origins when data set is all positive, all negative or mixed. Origin is now always from the line down.

## [13.0.1] - 2024-04-16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Divider,
} from './components';
import {LineChart} from '../../LineChart';
import {DEFAULT_THEME, DEFAULT_THEME_NAME} from '@shopify/polaris-viz-core';
import {DEFAULT_THEME_NAME} from '@shopify/polaris-viz-core';

<Meta
title="Shared/Formatting Values"
Expand Down

0 comments on commit 7c8c3c9

Please sign in to comment.