Skip to content

Commit e0401fd

Browse files
committed
fix: adjust stat chart sizes
1 parent b22f762 commit e0401fd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/components/uis/Scouter/StatsChart.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import SvgStatsWater from '../../svgs/SvgStatsWater';
1616

1717
type Axis = {x: number; y: number};
1818

19-
const Container = styled.View`
19+
const Container = styled.View<{width: number}>`
2020
padding: 32px;
21+
width: ${({width}) => width} + 'px';
2122
2223
justify-content: center;
2324
align-items: center;
@@ -229,7 +230,7 @@ const StatsChart = ({
229230
const posTree = convertPosition(centerPosition, tree, 'tree');
230231

231232
return (
232-
<Container style={{width: width + 72}}>
233+
<Container width={width + 72}>
233234
<StatUnits centerPosition={centerPosition} onPressStat={onPressStat} />
234235
<StatsContainer>
235236
<ImageBackground

src/components/uis/Scouter/index.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Scouter = ({
3030
>;
3131
style?: StyleProp<ViewStyle>;
3232
}): ReactElement => {
33+
const [width, setWidth] = useState(0);
3334
const [selectedStat, setSelectedStat] = useState<StatType | null>(null);
3435
const [tierName, setTierName] = useState<ScoreType['tierName']>('Silver');
3536
const pluginStats = !githubLogin
@@ -68,8 +69,14 @@ const Scouter = ({
6869
};
6970

7071
return (
71-
<Container style={style}>
72+
<Container
73+
style={style}
74+
onLayout={(e) => {
75+
setWidth(e.nativeEvent.layout.width);
76+
}}
77+
>
7278
<StatsChart
79+
width={width > 330 ? 330 : width - 64}
7380
selectedStat={selectedStat}
7481
onPressStat={onPressStat}
7582
statsScore={{

0 commit comments

Comments
 (0)