How to use backgroundStyles method in storybook-root

Best JavaScript code snippet using storybook-root

CurrentWeather.js

Source:CurrentWeather.js Github

copy

Full Screen

1import React, { useState, useEffect } from "react";2import { SafeAreaView, Text, View, Pressable, Dimensions, ScrollView, Modal, Image } from "react-native";3import { getWeatherData } from "../redux/actions";4import { connect } from "react-redux";5import { useDispatch } from "react-redux";6import HourlyForecast from "./HourlyForecast";7import WeeklyForecast from "./WeeklyForecast";8import { LineChart } from "react-native-chart-kit";9import styles from "../assets/style/CurrentStyles";10import HourlyStyles from "../assets/style/HourlyStyles";11import WeeklyStyles from "../assets/style/WeeklyStyles";12import backgroundStyles from "../assets/style/BackgroundColors";13import { LinearGradient } from "expo-linear-gradient";14import Ionicons from "react-native-vector-icons/Ionicons";15import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";16const screenWidth = Dimensions.get("window").width;17const data = {18 datasets: [19 {20 data: [1, 2],21 color: (opacity = 1) => `rgba(119, 190, 255, ${opacity})`, // optional22 strokeWidth: 3, // optional23 },24 ],25};26const chartConfig = {27 backgroundGradientFrom: "#CEB68C",28 backgroundGradientFromOpacity: 0.2,29 backgroundGradientTo: "#CEB68C",30 backgroundGradientToOpacity: 0.2,31 color: (opacity = 1) => `rgba(26, 255, 146, ${opacity})`,32 strokeWidth: 2, // optional, default 333 barPercentage: 0.5,34 useShadowColorFromDataset: false, // optional35 propsForDots: {36 r: "0",37 },38 fillShadowGradient: "#77BEFF",39 fillShadowGradientOpacity: 2,40};41function CurrentWeather({ weatherData }) {42 const [modalVisible, setModalVisible] = useState(false);43 const dispatch = useDispatch();44 useEffect(() => {45 dispatch(getWeatherData());46 }, []);47 var hours = new Date().getHours();48 const earlyMorning = hours <= 6;49 const morning = hours >= 7 && hours < 12;50 const afternoon = hours >= 12 && hours < 15;51 const evening = hours >= 15 && hours < 17;52 const night = hours >= 17 && hours <= 24;53 return weatherData.length === 0 ? (54 <SafeAreaView>55 <Text>loading...</Text>56 </SafeAreaView>57 ) : (58 <ScrollView>59 <View60 // TODO: Change to switch cases61 style={62 earlyMorning63 ? backgroundStyles.earlyContainer64 : morning && weatherData.current.weather[0].main === "Clear"65 ? backgroundStyles.morningContainer66 : morning && weatherData.current.weather[0].main === "Clouds"67 ? backgroundStyles.morningContainerOvercast68 : morning && weatherData.current.weather[0].main === "Drizzle"69 ? backgroundStyles.morningContainerRain70 : morning && weatherData.current.weather[0].main === "Rain"71 ? backgroundStyles.morningContainerRain72 : morning && weatherData.current.weather[0].main === "Thunderstorm"73 ? backgroundStyles.morningContainerRain74 : morning && weatherData.current.weather[0].main === "Snow"75 ? backgroundStyles.morningContainerSnow76 : afternoon && weatherData.current.weather[0].main === "Clear"77 ? backgroundStyles.afternoonContainer78 : afternoon && weatherData.current.weather[0].main === "Clouds"79 ? backgroundStyles.afternoonContainerOvercast80 : afternoon && weatherData.current.weather[0].main === "Drizzle"81 ? backgroundStyles.afternoonContainerRain82 : afternoon && weatherData.current.weather[0].main === "Rain"83 ? backgroundStyles.afternoonContainerRain84 : afternoon && weatherData.current.weather[0].main === "Thunderstorm"85 ? backgroundStyles.afternoonContainerRain86 : afternoon && weatherData.current.weather[0].main === "Snow"87 ? backgroundStyles.afternoonContainerSnow88 : evening && weatherData.current.weather[0].main === "Clear"89 ? backgroundStyles.eveningContainer90 : evening && weatherData.current.weather[0].main === "Clouds"91 ? backgroundStyles.eveningContainerOvercast92 : evening && weatherData.current.weather[0].main === "Drizzle"93 ? backgroundStyles.eveningContainerRain94 : evening && weatherData.current.weather[0].main === "Rain"95 ? backgroundStyles.eveningContainerRain96 : evening && weatherData.current.weather[0].main === "Thunderstorm"97 ? backgroundStyles.eveningContainerRain98 : evening && weatherData.current.weather[0].main === "Snow"99 ? backgroundStyles.eveningContainerSnow100 : night101 ? backgroundStyles.nightContainer102 : null103 }104 >105 {earlyMorning ? (106 <LinearGradient107 start={{ x: 1, y: 0 }}108 end={{ x: 0, y: 1 }}109 colors={["rgb(0, 0, 0)", "transparent"]}110 style={backgroundStyles.background}111 />112 ) : morning && weatherData.current.weather[0].main === "Clear" ? (113 <LinearGradient114 start={{ x: 1, y: 0 }}115 end={{ x: 0, y: 1 }}116 colors={["rgba(255,184,0,100)", "transparent"]}117 style={backgroundStyles.background}118 />119 ) : morning && weatherData.current.weather[0].main === "Clouds" ? (120 <LinearGradient121 start={{ x: 1, y: 0 }}122 end={{ x: 0, y: 1 }}123 colors={["rgba(219, 226, 251, 100)", "transparent"]}124 style={backgroundStyles.background}125 />126 ) : morning && weatherData.current.weather[0].main === "Drizzle" ? (127 <LinearGradient128 start={{ x: 1, y: 0 }}129 end={{ x: 0, y: 1 }}130 colors={["rgba(204, 215, 255, 100)", "transparent"]}131 style={backgroundStyles.background}132 />133 ) : morning && weatherData.current.weather[0].main === "Rain" ? (134 <LinearGradient135 start={{ x: 1, y: 0 }}136 end={{ x: 0, y: 1 }}137 colors={["rgba(204, 215, 255, 100)", "transparent"]}138 style={backgroundStyles.background}139 />140 ) : morning && weatherData.current.weather[0].main === "Thunderstorm" ? (141 <LinearGradient142 start={{ x: 1, y: 0 }}143 end={{ x: 0, y: 1 }}144 colors={["rgba(204, 215, 255, 100)", "transparent"]}145 style={backgroundStyles.background}146 />147 ) : morning && weatherData.current.weather[0].main === "Snow" ? (148 <LinearGradient149 start={{ x: 1, y: 0 }}150 end={{ x: 0, y: 1 }}151 colors={["rgba(63, 174, 255, 100)", "transparent"]}152 style={backgroundStyles.background}153 />154 ) : afternoon && weatherData.current.weather[0].main === "Clear" ? (155 <LinearGradient156 start={{ x: 1, y: 0 }}157 end={{ x: 0, y: 1 }}158 colors={["rgba(255, 184, 0, 100)", "transparent"]}159 style={backgroundStyles.background}160 />161 ) : afternoon && weatherData.current.weather[0].main === "Clouds" ? (162 <LinearGradient163 start={{ x: 1, y: 0 }}164 end={{ x: 0, y: 1 }}165 colors={["rgba(168, 175, 198, 100)", "transparent"]}166 style={backgroundStyles.background}167 />168 ) : afternoon && weatherData.current.weather[0].main === "Drizzle" ? (169 <LinearGradient170 start={{ x: 1, y: 0 }}171 end={{ x: 0, y: 1 }}172 colors={["rgba(136, 149, 195, 100)", "transparent"]}173 style={backgroundStyles.background}174 />175 ) : afternoon && weatherData.current.weather[0].main === "Rain" ? (176 <LinearGradient177 start={{ x: 1, y: 0 }}178 end={{ x: 0, y: 1 }}179 colors={["rgba(136, 149, 195, 100)", "transparent"]}180 style={backgroundStyles.background}181 />182 ) : afternoon && weatherData.current.weather[0].main === "Thunderstorm" ? (183 <LinearGradient184 start={{ x: 1, y: 0 }}185 end={{ x: 0, y: 1 }}186 colors={["rgba(136, 149, 195, 100)", "transparent"]}187 style={backgroundStyles.background}188 />189 ) : afternoon && weatherData.current.weather[0].main === "Snow" ? (190 <LinearGradient191 start={{ x: 1, y: 0 }}192 end={{ x: 0, y: 1 }}193 colors={["rgba(0, 50, 86, 100)", "transparent"]}194 style={backgroundStyles.background}195 />196 ) : evening && weatherData.current.weather[0].main === "Clear" ? (197 <LinearGradient198 start={{ x: 1, y: 0 }}199 end={{ x: 0, y: 1 }}200 colors={["rgb(202, 145, 0)", "transparent"]}201 style={backgroundStyles.background}202 />203 ) : evening && weatherData.current.weather[0].main === "Clouds" ? (204 <LinearGradient205 start={{ x: 1, y: 0 }}206 end={{ x: 0, y: 1 }}207 colors={["rgba(120, 124, 140, 100)", "transparent"]}208 style={backgroundStyles.background}209 />210 ) : evening && weatherData.current.weather[0].main === "Drizzle" ? (211 <LinearGradient212 start={{ x: 1, y: 0 }}213 end={{ x: 0, y: 1 }}214 colors={["rgba(99, 109, 146, 100)", "transparent"]}215 style={backgroundStyles.background}216 />217 ) : evening && weatherData.current.weather[0].main === "Rain" ? (218 <LinearGradient219 start={{ x: 1, y: 0 }}220 end={{ x: 0, y: 1 }}221 colors={["rgba(99, 109, 146, 100)", "transparent"]}222 style={backgroundStyles.background}223 />224 ) : evening && weatherData.current.weather[0].main === "Thunderstorm" ? (225 <LinearGradient226 start={{ x: 1, y: 0 }}227 end={{ x: 0, y: 1 }}228 colors={["rgba(99, 109, 146, 100)", "transparent"]}229 style={backgroundStyles.background}230 />231 ) : evening && weatherData.current.weather[0].main === "Snow" ? (232 <LinearGradient233 start={{ x: 1, y: 0 }}234 end={{ x: 0, y: 1 }}235 colors={["rgba(0, 24, 41, 100)", "transparent"]}236 style={backgroundStyles.background}237 />238 ) : night ? (239 <LinearGradient240 start={{ x: 1, y: 0 }}241 end={{ x: 0, y: 1 }}242 colors={["rgb(0, 0, 0)", "transparent"]}243 style={backgroundStyles.background}244 />245 ) : null}246 <SafeAreaView style={styles.topContainer}>247 <View style={styles.opacityTopBackground}></View>248 <View style={styles.topContent}>249 <View style={styles.rightColumn}>250 <Text style={styles.cityText}>Phoenix</Text>251 <Text style={styles.rigthTempText}>{Math.round(weatherData.current.temp)}°</Text>252 <>253 {weatherData.current.weather[0].main === "Clear" ? (254 <>255 <View style={styles.condition}>256 <Text style={styles.conditionText}>257 {weatherData.current.weather[0].main}258 </Text>259 </View>260 </>261 ) : weatherData.current.weather[0].main === "Clouds" ? (262 <>263 <View style={styles.conditionCkouds}>264 <Text style={styles.conditionText}>265 {weatherData.current.weather[0].main}266 </Text>267 </View>268 </>269 ) : weatherData.current.weather[0].main === "Drizzle" ? (270 <>271 <View style={styles.conditionRain}>272 <Text style={styles.conditionText}>273 {weatherData.current.weather[0].main}274 </Text>275 </View>276 </>277 ) : weatherData.current.weather[0].main === "Rain" ? (278 <>279 <View style={styles.conditionRain}>280 <Text style={styles.conditionText}>281 {weatherData.current.weather[0].main}282 </Text>283 </View>284 </>285 ) : weatherData.current.weather[0].main === "ThunderStorm" ? (286 <>287 <View style={styles.conditionRain}>288 <Text style={styles.conditionText}>289 {weatherData.current.weather[0].main}290 </Text>291 </View>292 </>293 ) : weatherData.current.weather[0].main === "Snow" ? (294 <>295 <View style={styles.conditionSnow}>296 <Text style={styles.conditionText}>297 {weatherData.current.weather[0].main}298 </Text>299 </View>300 </>301 ) : null}302 </>303 <Text style={styles.hiloTemp}>304 L: {Math.round(weatherData.daily[0].temp.min)}° H:{" "}305 {Math.round(weatherData.daily[0].temp.max)}°306 </Text>307 </View>308 <View style={{ marginBottom: 35, marginLeft: 10 }}>309 <Image310 source={{311 uri:312 "http://openweathermap.org/img/wn/" +313 weatherData.current.weather[0].icon +314 "@4x.png",315 }}316 style={styles.image}317 />318 </View>319 </View>320 </SafeAreaView>321 <View style={styles.currentDetails}>322 <View323 style={{324 justifyContent: "center",325 alignItems: "center",326 flexDirection: "row",327 paddingRight: 5,328 }}329 >330 <Ionicons name="ios-rainy" color="white" size={15} />331 <>332 {weatherData.daily[0].pop > 0 ? (333 <Text style={styles.details}>{Math.round(weatherData.daily[0].pop * 100)} %</Text>334 ) : (335 <Text style={styles.details}>0% </Text>336 )}337 </>338 </View>339 <View340 style={{341 justifyContent: "center",342 alignItems: "center",343 flexDirection: "row",344 paddingLeft: 5,345 }}346 >347 <MaterialCommunityIcons name="weather-windy-variant" color="white" size={14} />348 <Text style={styles.details}>{weatherData.current.wind_speed} kh/m</Text>349 </View>350 </View>351 {/*Conditonal Alert Div*/}352 {/* {weatherData.alerts.length === undefined ? null : (353 <View style={styles.alert}>354 <View style={styles.opacityAlertBackground}></View>355 <Modal356 animationType="slide"357 transparent={true}358 visible={modalVisible}359 onRequestClose={() => {360 Alert.alert("Modal has been closed.");361 setModalVisible(!modalVisible);362 }}363 >364 <View style={styles.centeredView}>365 <View style={styles.modalView}>366 <Text style={styles.modalText}>{weatherData.alerts.alert[1].desc}</Text>367 <Pressable368 style={[styles.button, styles.buttonClose]}369 onPress={() => setModalVisible(!modalVisible)}370 >371 <Text style={styles.textStyle}>Close</Text>372 </Pressable>373 </View>374 </View>375 </Modal>376 <Pressable style={styles.alertMessage} onPress={() => setModalVisible(true)}>377 <Text style={styles.textStyle}> Alert! {weatherData.alerts.alert[1].event}</Text>378 </Pressable>379 </View>380 )} */}381 {/*Conditonal Rain or Snow Div*/}382 {/* {weatherData.forecast.forecastday[0].day.daily_chance_of_rain ||383 weatherData.forecast.forecastday[0].day.daily_chance_of_snow > 0 ? (384 <View style={styles.raining}>385 <LineChart386 data={data}387 width={screenWidth - 20}388 height={70}389 verticalLabelRotation={10}390 chartConfig={chartConfig}391 style={{ borderRadius: 10 }}392 bezier393 />394 </View>395 ) : null} */}396 <View style={HourlyStyles.middleContainer}>397 <View style={HourlyStyles.opacityMiddleBackground}></View>398 <HourlyForecast weatherData={weatherData} />399 </View>400 <View style={WeeklyStyles.bottomContainer}>401 <View style={WeeklyStyles.opacityBottomBackground}></View>402 <WeeklyForecast weatherData={weatherData} />403 </View>404 </View>405 </ScrollView>406 );407}408const mapStateToProps = (state) => {409 return {410 weatherData: state.weatherData,411 weatherDataFail: state.weatherDataFail,412 };413};414const mapDispatchToProps = {415 getWeatherData,416};...

Full Screen

Full Screen

NewLocation.js

Source:NewLocation.js Github

copy

Full Screen

1import React, { useState, useEffect } from "react";2import { useDispatch } from "react-redux";3import { connect } from "react-redux";4import { SafeAreaView, Text, View, Pressable, Dimensions, ScrollView, Modal, Image } from "react-native";5import { getWeatherData } from "../redux/actions";6import { saveLocation } from "../redux/actions";7import HourlyForecast from "./HourlyForecast";8import WeeklyForecast from "./WeeklyForecast";9import { LineChart } from "react-native-chart-kit";10import styles from "../assets/style/CurrentStyles";11import MyLocationsStyles from "../assets/style/MyLocationsStyles";12import HourlyStyles from "../assets/style/HourlyStyles";13import WeeklyStyles from "../assets/style/WeeklyStyles";14import backgroundStyles from "../assets/style/BackgroundColors";15import { LinearGradient } from "expo-linear-gradient";16import Ionicons from "react-native-vector-icons/Ionicons";17import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";18const screenWidth = Dimensions.get("window").width;19const data = {20 datasets: [21 {22 data: [1, 2],23 color: (opacity = 1) => `rgba(119, 190, 255, ${opacity})`, // optional24 strokeWidth: 3, // optional25 },26 ],27};28const chartConfig = {29 backgroundGradientFrom: "#CEB68C",30 backgroundGradientFromOpacity: 0.2,31 backgroundGradientTo: "#CEB68C",32 backgroundGradientToOpacity: 0.2,33 color: (opacity = 1) => `rgba(26, 255, 146, ${opacity})`,34 strokeWidth: 2, // optional, default 335 barPercentage: 0.5,36 useShadowColorFromDataset: false, // optional37 propsForDots: {38 r: "0",39 },40 fillShadowGradient: "#77BEFF",41 fillShadowGradientOpacity: 2,42};43function NewLocation({ city, weatherData, modalVisible, setModalVisible, query, setQuery }) {44 const dispatch = useDispatch();45 useEffect(() => {46 dispatch(getWeatherData());47 }, []);48 const onPressAdd = () => {49 dispatch(50 saveLocation({51 city: city.name,52 country: city.country,53 temp: city.main.temp,54 img: city.weather[0].icon,55 rain: "90%",56 wind: city.wind.speed,57 })58 );59 setModalVisible(!modalVisible);60 setQuery(!query);61 };62 var hours = new Date().getHours();63 const earlyMorning = hours <= 6;64 const morning = hours >= 7 && hours < 12;65 const afternoon = hours >= 12 && hours < 15;66 const evening = hours >= 15 && hours < 17;67 const night = hours >= 17 && hours <= 24;68 return weatherData.length === 0 ? (69 <SafeAreaView>70 <Text>loading...</Text>71 </SafeAreaView>72 ) : (73 <ScrollView>74 <View style={MyLocationsStyles.modalButtons}>75 <Pressable style={MyLocationsStyles.button} onPress={() => setModalVisible(!modalVisible)}>76 <Text style={MyLocationsStyles.textStyle}>Cancel</Text>77 </Pressable>78 <Pressable style={MyLocationsStyles.button} onPress={onPressAdd}>79 <Text style={MyLocationsStyles.textStyle}>Add</Text>80 </Pressable>81 </View>82 <View83 style={84 earlyMorning85 ? backgroundStyles.earlyContainer86 : morning && weatherData.current.weather[0].main === "Clear"87 ? backgroundStyles.morningContainer88 : morning && weatherData.current.weather[0].main === "Overcast"89 ? backgroundStyles.morningContainerOvercast90 : morning && weatherData.current.weather[0].main === "Rain"91 ? backgroundStyles.morningContainerRain92 : morning && weatherData.current.weather[0].main === "Snow"93 ? backgroundStyles.morningContainerSnow94 : afternoon && weatherData.current.weather[0].main === "Clear"95 ? backgroundStyles.afternoonContainer96 : afternoon && weatherData.current.weather[0].main === "Clouds"97 ? backgroundStyles.afternoonContainerOvercast98 : afternoon && weatherData.current.weather[0].main === "Rain"99 ? backgroundStyles.afternoonContainerRain100 : afternoon && weatherData.current.weather[0].main === "Snow"101 ? backgroundStyles.afternoonContainerSnow102 : evening && weatherData.current.weather[0].main === "Sunny"103 ? backgroundStyles.eveningContainer104 : evening && weatherData.current.weather[0].main === "Clouds"105 ? backgroundStyles.eveningContainerOvercast106 : evening && weatherData.current.weather[0].main === "Rain"107 ? backgroundStyles.eveningContainerRain108 : evening && weatherData.current.weather[0].main === "Snow"109 ? backgroundStyles.eveningContainerSnow110 : night111 ? backgroundStyles.nightContainer112 : null113 }114 >115 {earlyMorning ? (116 <LinearGradient117 start={{ x: 1, y: 0 }}118 end={{ x: 0, y: 1 }}119 colors={["rgb(0, 0, 0)", "transparent"]}120 style={backgroundStyles.background}121 />122 ) : morning && weatherData.current.weather[0].main === "Clear" ? (123 <LinearGradient124 start={{ x: 1, y: 0 }}125 end={{ x: 0, y: 1 }}126 colors={["rgba(255,184,0,100)", "transparent"]}127 style={backgroundStyles.background}128 />129 ) : morning && weatherData.current.weather[0].main === "Overcast" ? (130 <LinearGradient131 start={{ x: 1, y: 0 }}132 end={{ x: 0, y: 1 }}133 colors={["rgba(219, 226, 251, 100)", "transparent"]}134 style={backgroundStyles.background}135 />136 ) : morning && weatherData.current.weather[0].main === "Rain" ? (137 <LinearGradient138 start={{ x: 1, y: 0 }}139 end={{ x: 0, y: 1 }}140 colors={["rgba(204, 215, 255, 100)", "transparent"]}141 style={backgroundStyles.background}142 />143 ) : morning && weatherData.current.weather[0].main === "Snow" ? (144 <LinearGradient145 start={{ x: 1, y: 0 }}146 end={{ x: 0, y: 1 }}147 colors={["rgba(63, 174, 255, 100)", "transparent"]}148 style={backgroundStyles.background}149 />150 ) : afternoon && weatherData.current.weather[0].main === "Clear" ? (151 <LinearGradient152 start={{ x: 1, y: 0 }}153 end={{ x: 0, y: 1 }}154 colors={["rgba(255, 184, 0, 100)", "transparent"]}155 style={backgroundStyles.background}156 />157 ) : afternoon && weatherData.current.weather[0].main === "Overcast" ? (158 <LinearGradient159 start={{ x: 1, y: 0 }}160 end={{ x: 0, y: 1 }}161 colors={["rgba(168, 175, 198, 100)", "transparent"]}162 style={backgroundStyles.background}163 />164 ) : afternoon && weatherData.current.weather[0].main === "Rain" ? (165 <LinearGradient166 start={{ x: 1, y: 0 }}167 end={{ x: 0, y: 1 }}168 colors={["rgba(136, 149, 195, 100)", "transparent"]}169 style={backgroundStyles.background}170 />171 ) : afternoon && weatherData.current.weather[0].main === "Snow" ? (172 <LinearGradient173 start={{ x: 1, y: 0 }}174 end={{ x: 0, y: 1 }}175 colors={["rgba(0, 50, 86, 100)", "transparent"]}176 style={backgroundStyles.background}177 />178 ) : evening && weatherData.current.weather[0].main === "Sunny" ? (179 <LinearGradient180 start={{ x: 1, y: 0 }}181 end={{ x: 0, y: 1 }}182 colors={["rgb(202, 145, 0)", "transparent"]}183 style={backgroundStyles.background}184 />185 ) : evening && weatherData.current.weather[0].main === "Clouds" ? (186 <LinearGradient187 start={{ x: 1, y: 0 }}188 end={{ x: 0, y: 1 }}189 colors={["rgba(120, 124, 140, 100)", "transparent"]}190 style={backgroundStyles.background}191 />192 ) : evening && weatherData.current.weather[0].main === "Rain" ? (193 <LinearGradient194 start={{ x: 1, y: 0 }}195 end={{ x: 0, y: 1 }}196 colors={["rgba(99, 109, 146, 100)", "transparent"]}197 style={backgroundStyles.background}198 />199 ) : evening && weatherData.current.weather[0].main === "Snow" ? (200 <LinearGradient201 start={{ x: 1, y: 0 }}202 end={{ x: 0, y: 1 }}203 colors={["rgba(0, 24, 41, 100)", "transparent"]}204 style={backgroundStyles.background}205 />206 ) : night ? (207 <LinearGradient208 start={{ x: 1, y: 0 }}209 end={{ x: 0, y: 1 }}210 colors={["rgb(0, 0, 0)", "transparent"]}211 style={backgroundStyles.background}212 />213 ) : null}214 <SafeAreaView style={styles.topContainer}>215 <View style={styles.opacityTopBackground}></View>216 <View style={styles.topContent}>217 <View style={styles.rightColumn}>218 <Text style={styles.cityText}>{city.name}</Text>219 <Text style={styles.rigthTempText}>{Math.round(city.main.temp)}°</Text>220 <>221 {city.weather[0].main === "Rain" ? (222 <>223 <View style={styles.conditionRain}>224 <Text style={styles.conditionText}>225 {weatherData.current.weather[0].main}226 </Text>227 </View>228 </>229 ) : (230 <>231 <View style={styles.condition}>232 <Text style={styles.conditionText}>233 {weatherData.current.weather[0].main}234 </Text>235 </View>236 </>237 )}238 </>239 <Text style={styles.hiloTemp}>240 L: {Math.round(city.main.temp_min)}° H: {Math.round(city.main.temp_max)}°241 </Text>242 </View>243 <View style={{ marginBottom: 35, marginLeft: 10 }}>244 <Image245 source={{246 uri: "http://openweathermap.org/img/wn/" + city.weather[0].icon + "@4x.png",247 }}248 style={styles.image}249 />250 </View>251 </View>252 </SafeAreaView>253 <View style={styles.currentDetails}>254 <View255 style={{256 justifyContent: "center",257 alignItems: "center",258 flexDirection: "row",259 paddingRight: 5,260 }}261 >262 <Ionicons name="ios-rainy" color="white" size={15} />263 <>264 {weatherData.daily[0].pop > 0 ? (265 <Text style={styles.details}>{Math.round(weatherData.daily[0].pop * 100)} %</Text>266 ) : (267 <Text style={styles.details}>0% </Text>268 )}269 </>270 </View>271 <View272 style={{273 justifyContent: "center",274 alignItems: "center",275 flexDirection: "row",276 paddingLeft: 5,277 }}278 >279 <MaterialCommunityIcons name="weather-windy-variant" color="white" size={14} />280 <Text style={styles.details}>{city.wind.speed} kh/m</Text>281 </View>282 </View>283 <View style={HourlyStyles.middleContainer}>284 <View style={HourlyStyles.opacityMiddleBackground}></View>285 <HourlyForecast weatherData={weatherData} />286 </View>287 <View style={WeeklyStyles.bottomContainer}>288 <View style={WeeklyStyles.opacityBottomBackground}></View>289 <WeeklyForecast weatherData={weatherData} />290 </View>291 </View>292 </ScrollView>293 );294}295const mapStateToProps = (state) => {296 return {297 weatherData: state.weatherData,298 weatherDataFail: state.weatherDataFail,299 };300};301const mapDispatchToProps = {302 getWeatherData,303 saveLocation,304};...

Full Screen

Full Screen

save.js

Source:save.js Github

copy

Full Screen

1'use strict';2import classnames from 'classnames';3import { RichText, InnerBlocks } from '@wordpress/block-editor';4import { divider } from '../../../src/js/helper/helper';5export default function( { attributes, className } ) {6 const {7 wrapperTagName,8 titleTagName,9 title,10 subtitle,11 lede,12 backgroundHorizontalPosition,13 backgroundVerticalPosition,14 backgroundColor,15 backgroundColor2,16 backgroundColorAngle,17 textColor,18 isSlim,19 topDividerType,20 topDividerLevel,21 topDividerColor,22 bottomDividerType,23 bottomDividerLevel,24 bottomDividerColor,25 } = attributes;26 const Wrapper = wrapperTagName;27 const classes = classnames( 'smb-section', className );28 const topDividerClasses = classnames(29 'smb-section__divider',30 'smb-section__divider--top',31 `smb-section__divider--${ topDividerType }`32 );33 const bottomDividerClasses = classnames(34 'smb-section__divider',35 'smb-section__divider--bottom',36 `smb-section__divider--${ bottomDividerType }`37 );38 const containerClasses = classnames( 'c-container', {39 'u-slim-width': !! isSlim,40 } );41 const sectionStyles = {};42 if ( textColor ) {43 sectionStyles.color = textColor;44 }45 if ( 0 < backgroundVerticalPosition ) {46 if ( !! topDividerLevel ) {47 sectionStyles.backgroundColor = topDividerColor;48 }49 } else if ( 0 > backgroundVerticalPosition ) {50 if ( !! bottomDividerLevel ) {51 sectionStyles.backgroundColor = bottomDividerColor;52 }53 }54 const backgroundStyles = {};55 if ( backgroundColor ) {56 backgroundStyles.backgroundColor = backgroundColor;57 if ( backgroundColor2 ) {58 backgroundStyles.backgroundImage = `linear-gradient(${ backgroundColorAngle }deg, ${ backgroundColor } 0%, ${ backgroundColor2 } 100%)`;59 }60 if ( 0 < backgroundHorizontalPosition ) {61 backgroundStyles.left = `${ Math.abs(62 backgroundHorizontalPosition63 ) }%`;64 } else if ( 0 > backgroundHorizontalPosition ) {65 backgroundStyles.right = `${ Math.abs(66 backgroundHorizontalPosition67 ) }%`;68 }69 if ( 0 < backgroundVerticalPosition ) {70 backgroundStyles.top = `${ Math.abs(71 backgroundVerticalPosition72 ) }%`;73 } else if ( 0 > backgroundVerticalPosition ) {74 backgroundStyles.bottom = `${ Math.abs(75 backgroundVerticalPosition76 ) }%`;77 }78 }79 const innerStyles = {80 paddingTop: Math.abs( topDividerLevel ),81 paddingBottom: Math.abs( bottomDividerLevel ),82 };83 return (84 <Wrapper className={ classes } style={ sectionStyles }>85 { ( 0 < Object.keys( backgroundStyles ).length ||86 !! topDividerLevel ||87 !! bottomDividerLevel ) && (88 <div89 className="smb-section__background"90 style={ backgroundStyles }91 >92 { !! topDividerLevel && (93 <div className={ topDividerClasses }>94 { divider(95 topDividerType,96 topDividerLevel,97 topDividerColor98 ) }99 </div>100 ) }101 { !! bottomDividerLevel && (102 <div className={ bottomDividerClasses }>103 { divider(104 bottomDividerType,105 bottomDividerLevel,106 bottomDividerColor107 ) }108 </div>109 ) }110 </div>111 ) }112 <div className="smb-section__inner" style={ innerStyles }>113 <div className={ containerClasses }>114 { ! RichText.isEmpty( title ) &&115 ! RichText.isEmpty( subtitle ) &&116 'none' !== titleTagName && (117 <RichText.Content118 tagName="div"119 className="smb-section__subtitle"120 value={ subtitle }121 />122 ) }123 { ! RichText.isEmpty( title ) &&124 'none' !== titleTagName && (125 <RichText.Content126 tagName={ titleTagName }127 className="smb-section__title"128 value={ title }129 />130 ) }131 { ! RichText.isEmpty( title ) &&132 ! RichText.isEmpty( lede ) &&133 'none' !== titleTagName && (134 <RichText.Content135 tagName="div"136 className="smb-section__lede"137 value={ lede }138 />139 ) }140 <div className="smb-section__body">141 <InnerBlocks.Content />142 </div>143 </div>144 </div>145 </Wrapper>146 );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { withBackgroundStyles } from 'storybook-root';4import { withKnobs, text } from '@storybook/addon-knobs';5const stories = storiesOf('Button', module);6stories.addDecorator(withKnobs);7stories.addDecorator(withBackgroundStyles);8stories.add('with text', () => {9 const textValue = text('Text', 'Hello Button');10 return <button>{textValue}</button>;11});12stories.add('with some emoji', () => (13));14import { configure } from '@storybook/react';15addParameters({16 { name: 'twitter', value: '#00aced', default: true },17 { name: 'facebook', value: '#3b5998' },18});19configure(require.context('../src', true, /\.stories\.js$/), module);20import { addDecorator } from '@storybook/react';21import { withBackgroundStyles } from 'storybook-root';22addDecorator(withBackgroundStyles);23import '@storybook/addon-knobs/register';24import 'storybook-root/register';25 { name: 'twitter', value: '#00aced', default: true },26 { name: 'facebook', value: '#3b5998' },27];28const path = require('path');29module.exports = async ({ config, mode }) => {30 config.module.rules.push({31 include: path.resolve(__dirname, '../'),32 });33 return config;34};35import '@storybook/addon-knobs/register';36import 'storybook-root/register';37const path = require('path');38module.exports = async ({ config, mode }) => {39 config.module.rules.push({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { backgroundStyles } from 'storybook-root-decorator';2import { backgroundStyles } from 'storybook-root-decorator';3import { addParameters } from '@storybook/react';4import { backgrounds } from 'storybook-root-decorator';5addParameters({6 backgrounds: backgrounds([7 { name: 'white', value: '#fff', default: true },8 { name: 'black', value: '#000' },9});10import { withBackgrounds } from 'storybook-root-decorator';11storiesOf('Test', module)12 .addDecorator(withBackgrounds([13 { name: 'white', value: '#fff', default: true },14 { name: 'black', value: '#000' },15 .add('Test', () => <div>Test</div>);16import { addDecorator } from '@storybook/react';17import { withBackgrounds } from 'storybook-root-decorator';18addDecorator(withBackgrounds([19 { name: 'white', value: '#fff', default: true },20 { name: 'black', value: '#000' },21]));22import { withBackgrounds } from 'storybook-root-decorator';23storiesOf('Test', module)24 .addDecorator(withBackgrounds([25 { name: 'white', value: '#fff', default: true },26 { name: 'black', value: '#000' },27 .add('Test', () => <div>Test</div>);28import { addDecorator } from '@storybook/react';29import { withBackgrounds } from 'storybook-root-decorator';30addDecorator(withBackgrounds([31 { name: 'white', value: '#fff', default: true },32 { name: 'black', value: '#000' },33]));34import { withBackgrounds } from 'storybook-root-decorator';35storiesOf('Test', module)36 .addDecorator(withBackgrounds([37 { name: 'white', value: '#fff', default: true },38 { name: 'black', value: '#000' },39 .add('Test', () => <div>Test</div>);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { backgroundStyles } from 'storybook-root-provider'2const styles = {3}4export const App = () => (5 <div style={styles}>6import { addDecorator } from '@storybook/react'7import { withRootProvider } from 'storybook-root-provider'8addDecorator(withRootProvider({9 background: 'var(--color-primary)',10 color: 'var(--color-secondary)',11}))12import { addons } from '@storybook/addons'13import { withRootProvider } from 'storybook-root-provider'14addons.setConfig({15 theme: withRootProvider({16 background: 'var(--color-primary)',17 color: 'var(--color-secondary)',18 }),19})20 :root {21 --color-primary: red;22 --color-secondary: blue;23 }24 :root {25 --color-primary: green;26 --color-secondary: yellow;27 }28 :root {29 --color-primary: purple;30 --color-secondary: orange;31 }32 :root {33 --color-primary: pink;34 --color-secondary: black;35 }36import { addDecorator } from '@storybook/react'37import { withRootProvider } from 'storybook-root-provider'38addDecorator(withRootProvider({39 background: 'var(--color-primary)',40 color: 'var(--color-secondary)',41}))42import { backgroundStyles } from 'storybook-root-provider'

Full Screen

Using AI Code Generation

copy

Full Screen

1import { backgroundStyles } from 'storybook-root-provider';2const styles = backgroundStyles({ theme: 'light' });3const Test = () => (4 <div style={styles}>5);6export default Test;7import { addDecorator } from '@storybook/react';8import { withRootProvider } from 'storybook-root-provider';9addDecorator(withRootProvider());10import { addParameters } from '@storybook/react';11import { themes } from '@storybook/theming';12addParameters({13 backgrounds: {14 {15 },16 {17 },18 },19});20import { RootProvider } from 'storybook-root-provider';21const rootProvider = new RootProvider({22 themes: {23 light: {24 background: {25 },26 },27 dark: {28 background: {29 },30 },31 },32});33export const decorators = [rootProvider.decorator];34export const parameters = {35 backgrounds: {36 {37 },38 {39 },40 },41};42export const globalTypes = {43 theme: {44 toolbar: {45 },46 },47};48export const withRootProvider = rootProvider.withRootProvider;49export const backgroundStyles = rootProvider.backgroundStyles;50export const theme = rootProvider.theme;51export default rootProvider;52import { addParameters } from '@storybook/react';53import { themes } from '@storybook/theming';54addParameters({55 backgrounds: {56 {57 },58 {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';2import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';3import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';4import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';5import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';6import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';7import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';8import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';9import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';10import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';11import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';12import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';13import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';14import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';15import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';16import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';17import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';18import { backgroundStyles } from 'storybook-addon-root/backgroundStyles';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { backgroundStyles } from 'storybook-root-provider';2export const styles = {3};4import React from 'react';5import { storiesOf } from '@storybook/react';6import { withBackgrounds } from '@storybook/addon-backgrounds';7import { backgrounds } from 'storybook-root-provider';8import Test from './test';9storiesOf('Test', module)10 .addDecorator(withBackgrounds(backgrounds))11 .add('default', () => <Test />);12MIT © [Nikhil](

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful