diff --git a/package.json b/package.json index 5bdb1c6..5360411 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vela/ui", - "version": "0.6.29", + "version": "0.6.30", "description": "Vela React UI Toolkit", "main": "src/index.js", "scripts": { diff --git a/src/components/Speed.js b/src/components/Speed.js index 4a0015a..59c86e4 100644 --- a/src/components/Speed.js +++ b/src/components/Speed.js @@ -1,36 +1,40 @@ -import React, {useState, useEffect} from 'react' -import Text from './Text' -import Heading from './Typography/Heading' -import Paragraph from './Typography/Paragraph' -import convert from 'convert-units' -import {useSystem} from '../lib/useSystem' +import React, { useState, useEffect } from "react"; +import Text from "./Text"; +import Heading from "./Typography/Heading"; +import Paragraph from "./Typography/Paragraph"; +import convert from "convert-units"; +import { useSystem } from "../lib/useSystem"; -function Speed({ - speed, - size, - ...props -}) { - const system = useSystem() - const unit = system === 'metric' ? 'km/h' : 'm/h' - const displayUnit = unit === 'm/h' ? 'mi/h' : unit +function Speed({ speed, size, ...props }) { + const system = useSystem(); + const unit = system === "metric" ? "km/h" : "m/h"; + const displayUnit = unit === "m/h" ? "mi/h" : unit; - const [instantSpeed, setInstantSpeed] = useState(0) + const speedStyle = { + lineHeight: 56, + }; + + const [instantSpeed, setInstantSpeed] = useState(0); useEffect(() => { const interval = setInterval(() => { - if (instantSpeed > speed) setInstantSpeed(instantSpeed - 1) - if (instantSpeed < speed) setInstantSpeed(instantSpeed + 1) - }, 100) - return () => clearInterval(interval) - }) + if (instantSpeed > speed) setInstantSpeed(instantSpeed - 1); + if (instantSpeed < speed) setInstantSpeed(instantSpeed + 1); + }, 100); + return () => clearInterval(interval); + }); - const value = convert(instantSpeed).from('km/h').to(unit) + const value = convert(instantSpeed) + .from("km/h") + .to(unit); return ( <> - {value.toFixed(0)} + + {value.toFixed(0)} + {displayUnit} - ) + ); } -export default Speed +export default Speed; diff --git a/src/components/charts/Speedometer.js b/src/components/charts/Speedometer.js index aa71672..c244293 100644 --- a/src/components/charts/Speedometer.js +++ b/src/components/charts/Speedometer.js @@ -1,37 +1,21 @@ -import React from 'react' -import {View} from 'react-native' +import React from "react"; +import { View } from "react-native"; -import Speed from '../Speed' +import Speed from "../Speed"; const containerStyle = { - width: 96, + justifyContent: "space-between", + alignItems: "center", height: 96, - justifyContent: 'space-between', - alignItems: 'center', - overflow: 'hidden', - backgroundColor: 'transparent' -} - -const viewStyle = { - position: 'absolute', - left: -5 -} - -export default function Speedometer({speed = 0, size}) { - - const textStyle = { - textAlign: 'center' - } +}; +export default function Speedometer({ speed = 0, size }) { return ( <> - - {/* */} - - + + {/* */} + + ); }