Best JavaScript code snippet using playwright-internal
SelectableList.mjs
Source:SelectableList.mjs
...11import { CustomPropTypes, applyTheme } from "../../utils";12var StyledListAction = styled.div.withConfig({13 displayName: "SelectableList__StyledListAction",14 componentId: "jnbusj-0"15})(["align-options:center;box-sizing:border-box;display:flex;height:", ";padding-bottom:", ";padding-left:", ";padding-right:", ";padding-top:", ";@media (max-width:768px){height:", ";}"], applyTheme("SelectableList.height"), applyTheme("SelectableList.itemPaddingBottom"), applyTheme("SelectableList.itemPaddingLeft"), applyTheme("SelectableList.itemPaddingRight"), applyTheme("SelectableList.itemPaddingTop"), applyTheme("SelectableList.heightMobile"));16var BorderedListAction = styled(StyledListAction).withConfig({17 displayName: "SelectableList__BorderedListAction",18 componentId: "jnbusj-1"19})(["border-bottom-color:", ";border-bottom-style:", ";border-bottom-width:", ";border-left-color:", ";border-left-style:", ";border-left-width:", ";border-right-color:", ";border-right-style:", ";border-right-width:", ";"], applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"));20var StyledWrapper = styled.div.withConfig({21 displayName: "SelectableList__StyledWrapper",22 componentId: "jnbusj-2"23})(["padding-bottom:", ";padding-left:", ";padding-right:", ";padding-top:", ";"], applyTheme("SelectableList.itemPaddingBottom"), applyTheme("SelectableList.itemPaddingLeft"), applyTheme("SelectableList.itemPaddingRight"), applyTheme("SelectableList.itemPaddingTop"));24var StyledList = styled.div.withConfig({25 displayName: "SelectableList__StyledList",26 componentId: "jnbusj-3"27})(["width:100%;fieldset{border-color:transparent;margin:0;padding:0;}"]);28var BorderedList = styled(StyledList).withConfig({29 displayName: "SelectableList__BorderedList",30 componentId: "jnbusj-4"31})(["fieldset{border-bottom:none;border-left:none;border-right:none;border-top-color:", ";border-top-left-radius:", ";border-top-right-radius:", ";border-top-style:", ";border-top-width:", ";}> *:last-child{border-bottom-right-radius:", ";border-bottom-left-radius:", ";div:last-child{border-bottom-right-radius:", ";border-bottom-left-radius:", ";}}"], applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderRadius"), applyTheme("SelectableList.borderRadius"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.borderRadius"), applyTheme("SelectableList.borderRadius"), applyTheme("SelectableList.borderRadius"), applyTheme("SelectableList.borderRadius"));32var BorderedWrapper = styled.div.withConfig({33 displayName: "SelectableList__BorderedWrapper",34 componentId: "jnbusj-5"35})(["border-bottom-color:", ";border-bottom-style:", ";border-bottom-width:", ";border-left-color:", ";border-left-style:", ";border-left-width:", ";border-right-color:", ";border-right-style:", ";border-right-width:", ";padding-bottom:", ";padding-left:", ";padding-right:", ";padding-top:", ";> *:last-child{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}"], applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.itemPaddingBottom"), applyTheme("SelectableList.itemPaddingLeft"), applyTheme("SelectableList.itemPaddingRight"), applyTheme("SelectableList.itemPaddingTop"), applyTheme("SelectableList.borderRadius"), applyTheme("SelectableList.borderRadius"));36var HorizontalList = styled.div.withConfig({37 displayName: "SelectableList__HorizontalList",38 componentId: "jnbusj-6"39})(["display:flex;"]);40var HorizontalWrapper = styled.div.withConfig({41 displayName: "SelectableList__HorizontalWrapper",42 componentId: "jnbusj-7"43})(["border-left-color:", ";border-left-style:", ";border-left-width:", ";flex:1 1 auto;padding-bottom:", ";padding-left:", ";padding-right:", ";padding-top:", ";&:first-of-type{border-left:none;padding-right:", ";}&:last-of-type{padding-left:", ";}"], applyTheme("SelectableList.borderColor"), applyTheme("SelectableList.borderStyle"), applyTheme("SelectableList.borderWidth"), applyTheme("SelectableList.horizontalItemPaddingBottom"), applyTheme("SelectableList.horizontalItemPaddingLeft"), applyTheme("SelectableList.horizontalItemPaddingRight"), applyTheme("SelectableList.horizontalItemPaddingTop"), applyTheme("SelectableList.horizontalFirstItemPaddingRight"), applyTheme("SelectableList.horizontalLastItemPaddingLeft"));44var SelectableList =45/*#__PURE__*/46function (_Component) {47 _inherits(SelectableList, _Component);48 function SelectableList(props) {49 var _this;50 _classCallCheck(this, SelectableList);51 _this = _possibleConstructorReturn(this, _getPrototypeOf(SelectableList).call(this, props));52 _this.onChange = function (isChecked, value) {53 if (isChecked) {54 _this.setValue(value);55 }56 };57 _this.state = {...
SelectableList.js
Source:SelectableList.js
...6const StyledListAction = styled.div`7 align-options: center;8 box-sizing: border-box;9 display: flex;10 height: ${applyTheme("SelectableList.height")};11 padding-bottom: ${applyTheme("SelectableList.itemPaddingBottom")};12 padding-left: ${applyTheme("SelectableList.itemPaddingLeft")};13 padding-right: ${applyTheme("SelectableList.itemPaddingRight")};14 padding-top: ${applyTheme("SelectableList.itemPaddingTop")};15 @media (max-width: 768px) {16 height: ${applyTheme("SelectableList.heightMobile")};17 }18`;19const BorderedListAction = styled(StyledListAction)`20 border-bottom-color: ${applyTheme("SelectableList.borderColor")};21 border-bottom-style: ${applyTheme("SelectableList.borderStyle")};22 border-bottom-width: ${applyTheme("SelectableList.borderWidth")};23 border-left-color: ${applyTheme("SelectableList.borderColor")};24 border-left-style: ${applyTheme("SelectableList.borderStyle")};25 border-left-width: ${applyTheme("SelectableList.borderWidth")};26 border-right-color: ${applyTheme("SelectableList.borderColor")};27 border-right-style: ${applyTheme("SelectableList.borderStyle")};28 border-right-width: ${applyTheme("SelectableList.borderWidth")};29`;30const StyledWrapper = styled.div`31 padding-bottom: ${applyTheme("SelectableList.itemPaddingBottom")};32 padding-left: ${applyTheme("SelectableList.itemPaddingLeft")};33 padding-right: ${applyTheme("SelectableList.itemPaddingRight")};34 padding-top: ${applyTheme("SelectableList.itemPaddingTop")};35`;36const StyledList = styled.div`37 width: 100%;38 fieldset {39 border-color: transparent;40 margin: 0;41 padding: 0;42 }43`;44const BorderedList = styled(StyledList)`45 fieldset {46 border-bottom: none;47 border-left: none;48 border-right: none;49 border-top-color: ${applyTheme("SelectableList.borderColor")};50 border-top-left-radius: ${applyTheme("SelectableList.borderRadius")};51 border-top-right-radius: ${applyTheme("SelectableList.borderRadius")};52 border-top-style: ${applyTheme("SelectableList.borderStyle")};53 border-top-width: ${applyTheme("SelectableList.borderWidth")};54 }55 > *:last-child {56 border-bottom-right-radius: ${applyTheme("SelectableList.borderRadius")};57 border-bottom-left-radius: ${applyTheme("SelectableList.borderRadius")};58 div:last-child {59 border-bottom-right-radius: ${applyTheme("SelectableList.borderRadius")};60 border-bottom-left-radius: ${applyTheme("SelectableList.borderRadius")};61 }62 }63`;64const BorderedWrapper = styled.div`65 border-bottom-color: ${applyTheme("SelectableList.borderColor")};66 border-bottom-style: ${applyTheme("SelectableList.borderStyle")};67 border-bottom-width: ${applyTheme("SelectableList.borderWidth")};68 border-left-color: ${applyTheme("SelectableList.borderColor")};69 border-left-style: ${applyTheme("SelectableList.borderStyle")};70 border-left-width: ${applyTheme("SelectableList.borderWidth")};71 border-right-color: ${applyTheme("SelectableList.borderColor")};72 border-right-style: ${applyTheme("SelectableList.borderStyle")};73 border-right-width: ${applyTheme("SelectableList.borderWidth")};74 padding-bottom: ${applyTheme("SelectableList.itemPaddingBottom")};75 padding-left: ${applyTheme("SelectableList.itemPaddingLeft")};76 padding-right: ${applyTheme("SelectableList.itemPaddingRight")};77 padding-top: ${applyTheme("SelectableList.itemPaddingTop")};78 > *:last-child {79 border-bottom-left-radius: ${applyTheme("SelectableList.borderRadius")};80 border-bottom-right-radius: ${applyTheme("SelectableList.borderRadius")};81 }82`;83const HorizontalList = styled.div`84 display: flex;85`;86const HorizontalWrapper = styled.div`87 border-left-color: ${applyTheme("SelectableList.borderColor")};88 border-left-style: ${applyTheme("SelectableList.borderStyle")};89 border-left-width: ${applyTheme("SelectableList.borderWidth")};90 flex: 1 1 auto;91 padding-bottom: ${applyTheme("SelectableList.horizontalItemPaddingBottom")};92 padding-left: ${applyTheme("SelectableList.horizontalItemPaddingLeft")};93 padding-right: ${applyTheme("SelectableList.horizontalItemPaddingRight")};94 padding-top: ${applyTheme("SelectableList.horizontalItemPaddingTop")};95 &:first-of-type {96 border-left: none;97 padding-right: ${applyTheme("SelectableList.horizontalFirstItemPaddingRight")};98 }99 &:last-of-type {100 padding-left: ${applyTheme("SelectableList.horizontalLastItemPaddingLeft")};101 }102`;103class SelectableList extends Component {104 static isFormInput = true;105 static propTypes = {106 /**107 * You can provide a `className` prop that will be applied to the outermost DOM element108 * rendered by this component. We do not recommend using this for styling purposes, but109 * it can be useful as a selector in some situations.110 */111 className: PropTypes.string,112 /**113 * If you've set up a components context using114 * [@reactioncommerce/components-context](https://github.com/reactioncommerce/components-context)...
App.js
Source:App.js
1import React, {Component} from 'react';2import {createMuiTheme, MuiThemeProvider} from '@material-ui/core/styles';3import MomentUtils from '@date-io/moment';4import {MuiPickersUtilsProvider} from 'material-ui-pickers';5import {Redirect, Route, Switch} from 'react-router-dom';6import {connect} from 'react-redux';7import {IntlProvider} from 'react-intl'8import "../assets/vendors/style"9import indigoTheme from './themes/indigoTheme';10import cyanTheme from './themes/cyanTheme';11import orangeTheme from './themes/orangeTheme';12import amberTheme from './themes/amberTheme';13import pinkTheme from './themes/pinkTheme';14import blueTheme from './themes/blueTheme';15import purpleTheme from './themes/purpleTheme';16import greenTheme from './themes/greenTheme';17import darkTheme from './themes/darkTheme';18import AppLocale from '../lngProvider';19import {20 AMBER,21 BLUE,22 CYAN,23 DARK_AMBER,24 DARK_BLUE,25 DARK_CYAN,26 DARK_DEEP_ORANGE,27 DARK_DEEP_PURPLE,28 DARK_GREEN,29 DARK_INDIGO,30 DARK_PINK,31 DEEP_ORANGE,32 DEEP_PURPLE,33 GREEN,34 INDIGO,35 PINK36} from '../constants/ThemeColors';37import MainApp from '../app/index';38import SignIn from './SignIn';39import SignUp from './SignUp';40import forgotPassword from './forgotPassword';41import landingpage from './LandingPage';42import {setInitUrl} from '../actions/Auth';43import RTL from '../util/RTL';44import asyncComponent from '../util/asyncComponent';45const RestrictedRoute = ({component: Component, authUser, ...rest}) =>46 <Route47 {...rest}48 render={props =>49 authUser50 ? <Component {...props} />51 : <Redirect52 to={{53 pathname: '/signin',54 state: {from: props.location}55 }}56 />}57 />;58class App extends Component {59 componentWillMount() {60 window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true;61 if (this.props.initURL === '') {62 this.props.setInitUrl(this.props.history.location.pathname);63 }64 }65 getColorTheme(themeColor, applyTheme) {66 switch (themeColor) {67 case INDIGO: {68 applyTheme = createMuiTheme(indigoTheme);69 break;70 }71 case CYAN: {72 applyTheme = createMuiTheme(cyanTheme);73 break;74 }75 case AMBER: {76 applyTheme = createMuiTheme(amberTheme);77 break;78 }79 case DEEP_ORANGE: {80 applyTheme = createMuiTheme(orangeTheme);81 break;82 }83 case PINK: {84 applyTheme = createMuiTheme(pinkTheme);85 break;86 }87 case BLUE: {88 applyTheme = createMuiTheme(blueTheme);89 break;90 }91 case DEEP_PURPLE: {92 applyTheme = createMuiTheme(purpleTheme);93 break;94 }95 case GREEN: {96 applyTheme = createMuiTheme(greenTheme);97 break;98 }99 case DARK_INDIGO: {100 applyTheme = createMuiTheme(indigoTheme);101 break;102 }103 case DARK_CYAN: {104 applyTheme = createMuiTheme(cyanTheme);105 break;106 }107 case DARK_AMBER: {108 applyTheme = createMuiTheme(amberTheme);109 break;110 }111 case DARK_DEEP_ORANGE: {112 applyTheme = createMuiTheme(orangeTheme);113 break;114 }115 case DARK_PINK: {116 applyTheme = createMuiTheme(pinkTheme);117 break;118 }119 case DARK_BLUE: {120 applyTheme = createMuiTheme(blueTheme);121 break;122 }123 case DARK_DEEP_PURPLE: {124 applyTheme = createMuiTheme(purpleTheme);125 break;126 }127 case DARK_GREEN: {128 applyTheme = createMuiTheme(greenTheme);129 break;130 }131 default :132 createMuiTheme(indigoTheme);133 }134 return applyTheme;135 }136 render() {137 const {match, location, themeColor, isDarkTheme, locale, authUser, initURL, isDirectionRTL} = this.props;138 let applyTheme = createMuiTheme(indigoTheme);139 if (isDarkTheme) {140 document.body.classList.add('dark-theme');141 applyTheme = createMuiTheme(darkTheme)142 } else {143 applyTheme = this.getColorTheme(themeColor, applyTheme);144 }145 if (location.pathname === '/') {146 if (authUser === null) {147 return (<Redirect to={'/landingpage'}/>);148 } else if (initURL === '' || initURL === '/' || initURL === '/signin' || location.pathname=="/forgot-password") {149 return (<Redirect to={'/app/dashboard'}/>);150 } else {151 return (<Redirect to={initURL}/>);152 }153 }154 if (isDirectionRTL) {155 applyTheme.direction = 'rtl';156 document.body.classList.add('rtl')157 } else {158 document.body.classList.remove('rtl');159 applyTheme.direction = 'ltr';160 }161 const currentAppLocale = AppLocale[locale.locale];162 return (163 <MuiThemeProvider theme={applyTheme}>164 <MuiPickersUtilsProvider utils={MomentUtils}>165 <IntlProvider166 locale={currentAppLocale.locale}167 messages={currentAppLocale.messages}>168 <RTL>169 <div className="app-main">170 <Switch>171 <RestrictedRoute path={`${match.url}app`} authUser={authUser}172 component={MainApp}/>173 <Route path='/signin' component={SignIn}/>174 <Route path='/signup' component={SignUp}/>175 <Route path='/forgot-password' component={forgotPassword}/>176 <Route path='/' component={landingpage}/>177 <Route178 component={asyncComponent(() => import('../app/routes/extraPages/routes/404'))}/>179 </Switch>180 </div>181 </RTL>182 </IntlProvider>183 </MuiPickersUtilsProvider>184 </MuiThemeProvider>185 );186 }187}188const mapStateToProps = ({settings, auth}) => {189 const {themeColor, sideNavColor, darkTheme, locale, isDirectionRTL} = settings;190 const {authUser, initURL} = auth;191 return {themeColor, sideNavColor, isDarkTheme: darkTheme, locale, isDirectionRTL, authUser, initURL}192};...
Sidebar.js
Source:Sidebar.js
...16} from "@reactioncommerce/components/utils";17import { Translation } from "/imports/plugins/core/ui/client/components";18const Drawer = styledMUI(MUIDrawer, { paper: "Paper" })`19 .Paper {20 width: ${applyTheme("Sidebar.drawerWidth")};21 }22`;23const Divider = styledMUI(MUIDivider)`24 padding-top: ${applyTheme("Sidebar.dividerHeight")};;25 background-color: transparent;26`;27const List = styledMUI(MUIList)`28 padding-top: 0;29 overflow: auto;30`;31const ListItem = styledMUI(MUIListItem)`32 padding: 0;33`;34const ListItemIcon = styledMUI(MUIListItemIcon)`35 color: ${applyTheme("Sidebar.iconColor")};36 justify-content: ${applyTheme("Sidebar.listItemIconHorizontalAlign")};37 padding-top: ${applyTheme("Sidebar.listItemIconPaddingTop")};38 padding-right: ${applyTheme("Sidebar.listItemIconPaddingRight")};39 padding-bottom: ${applyTheme("Sidebar.listItemIconPaddingBottom")};40 padding-left: ${applyTheme("Sidebar.listItemIconPaddingLeft")};41 width: ${applyTheme("Sidebar.iconBarWidth")};42 /*43 * FontAwesome icons respect this font-size to determine icon height while other44 * SVGs should be designed to be 100% height. Generally you'll want listItemIconMaxHeight45 * to be listItemIconFontSize + listItemIconPaddingTop + listItemIconPaddingBottom46 */47 font-size: ${applyTheme("Sidebar.listItemIconFontSize")};48 max-height: ${applyTheme("Sidebar.listItemIconMaxHeight")};49 /* remove margin from default MUI theme */50 margin-right: 0;51`;52const ListItemText = styledMUI(MUIListItemText)`53 ${addTypographyStyles("SidebarMenu", "bodyText")};54`;55const LogoArea = styled.div`56 display: flex;57 justify-content: ${applyTheme("Sidebar.logoHorizontalAlign")};58 padding-top: ${applyTheme("Sidebar.logoPaddingTop")};59 padding-bottom: ${applyTheme("Sidebar.logoPaddingBottom")};60 padding-left: ${applyTheme("Sidebar.logoPaddingLeft")};61 padding-right: ${applyTheme("Sidebar.logoPaddingRight")};62 margin-left: ${applyTheme("Sidebar.iconBarWidth")};63`;64const StyledNav = styled.nav`65 background: ${applyTheme("Sidebar.menuBarBackground")};66 display: flex;67 flex-direction: column;68 height: 100%;69`;70const activeClassName = "nav-item-active";71const Link = styled(NavLink).attrs({72 activeClassName73})`74 &.${activeClassName} span {75 color: ${applyTheme("Sidebar.activeMenuItemColor")};76 }77`;78export default class Sidebar extends Component {79 static propTypes = {80 isMobile: PropTypes.bool,81 isSidebarOpen: PropTypes.bool.isRequired,82 onDrawerClose: PropTypes.func.isRequired,83 routes: PropTypes.array84 }85 renderNavigationMenuItems(settings = false) {86 const { routes } = this.props;87 const filteredRoutes = settings ?88 routes.filter(({ isNavigationLink, isSetting }) => isNavigationLink && isSetting) :89 routes.filter(({ isNavigationLink, isSetting }) => isNavigationLink && !isSetting);...
ThemePicker.js
Source:ThemePicker.js
2import { connect } from 'react-redux'3import { Link } from 'react-router-dom'4import { handleApplyTheme } from '../../actions/widget'5class ThemePicker extends Component {6 applyTheme(e, theme) {7 this.props.dispatch(handleApplyTheme(theme))8 }9 isCurrentTheme(listTheme) {10 return this.props.theme === listTheme11 }12 render() {13 return (14 <div className='design_editor_section main'>15 <div className='section'>16 <h5>Select a theme to apply or modify</h5>17 </div>18 <div className={ this.isCurrentTheme('default-theme') ? 'section active' : 'section' }>19 <div>20 <i className={ this.isCurrentTheme('default-theme') ? 'fas fa-check-circle' : 'far fa-circle' } 21 onClick={(e) => this.applyTheme(e, 'default-theme')}></i>22 <Link to='design-editor/default-theme' className='theme_name' onClick={(e) => this.applyTheme(e, 'default-theme')}>23 Pixlee - Default Theme24 </Link>25 </div>26 <Link to='design-editor/default-theme' onClick={(e) => this.applyTheme(e, 'default-theme')}>27 <i className="far fa-chevron-right"></i>28 </Link>29 </div>30 <div className={ this.isCurrentTheme('minimalist-modern') ? 'section active' : 'section' }>31 <div>32 <i className={ this.isCurrentTheme('minimalist-modern') ? 'fas fa-check-circle' : 'far fa-circle' } 33 onClick={(e) => this.applyTheme(e, 'minimalist-modern')}></i>34 <Link to='design-editor/default-theme' className='theme_name' onClick={(e) => this.applyTheme(e, 'minimalist-modern')}>35 Pixlee - Minimalist Modern36 </Link>37 </div>38 <Link to='design-editor/default-theme' onClick={(e) => this.applyTheme(e, 'minimalist-modern')}>39 <i className="far fa-chevron-right"></i>40 </Link>41 </div>42 <div className={ this.isCurrentTheme('black-and-white') ? 'section active' : 'section' }>43 <div>44 <i className={ this.isCurrentTheme('black-and-white') ? 'fas fa-check-circle' : 'far fa-circle' } 45 onClick={(e) => this.applyTheme(e, 'black-and-white')}></i>46 <Link to='design-editor/black-&-white' className='theme_name' onClick={(e) => this.applyTheme(e, 'black-and-white')}>47 Pixlee - Black & White48 </Link>49 </div>50 <Link to='design-editor/default-theme' onClick={(e) => this.applyTheme(e, 'black-and-white')}>51 <i className="far fa-chevron-right"></i>52 </Link>53 </div>54 <div className={ this.isCurrentTheme('paper-composition') ? 'section active' : 'section' }>55 <div>56 <i className={ this.isCurrentTheme('paper-composition') ? 'fas fa-check-circle' : 'far fa-circle' } 57 onClick={(e) => this.applyTheme(e, 'paper-composition')}></i>58 <Link to='design-editor/default-theme' className='theme_name' onClick={(e) => this.applyTheme(e, 'paper-composition')}>59 Pixlee - Paper Composition60 </Link>61 </div>62 <Link to='design-editor/default-theme' onClick={(e) => this.applyTheme(e, 'paper-composition')}>63 <i className="far fa-chevron-right"></i>64 </Link>65 </div>66 </div>67 )68 }69}70function mapStateToProps({ theme }) {71 return {72 theme73 }74}...
DisplayBoard.js
Source:DisplayBoard.js
1import React, { Component } from "react";2import { BetContext } from "./BetContext";3import "./index.css";4export default class DisplayBoard extends Component {5 constructor() {6 super();7 this.state = {8 stakes: 4,9 unit: 44.56,10 bet_price: 0,11 winning_average: 2212 };13 this.handleStakes = this.handleStakes.bind(this);14 this.handleBetPrice = this.handleBetPrice.bind(this);15 this.handleResetBetPrice = this.handleResetBetPrice.bind(this);16 this.handleResetStakes = this.handleResetStakes.bind(this);17 }18 //event handler for stakes click.19 handleStakes() {20 this.setState({ stakes: this.state.stakes * 2 });21 }22 //event handler for Price click.23 handleBetPrice() {24 this.setState({ bet_price: this.state.bet_price + this.state.unit });25 }26 //event handler for reset price click.27 handleResetBetPrice() {28 this.setState({ bet_price: this.state.bet_price * 0 });29 }30 //event handler for reset stakes click.31 handleResetStakes() {32 this.setState({ stakes: this.state.stakes * 0 + 4 });33 }34 static contextType = BetContext;35 render() {36 const { lightTheme, lightOption, darkOption } = this.context;37 //console.log(lightTheme, lightOption, darkOption);38 const applyTheme = lightTheme ? lightOption : darkOption;39 return (40 <div41 className="main-div"42 style={{ backgroundColor: applyTheme.backgroundHex }}43 >44 <button45 style={{46 color: applyTheme.fontMode,47 backgroundColor: applyTheme.buttonHex48 }}49 className="my-button"50 >51 {this.state.stakes}52 </button>53 <button54 style={{55 color: applyTheme.fontMode,56 backgroundColor: applyTheme.buttonHex57 }}58 className="my-button"59 >60 {this.state.unit}61 </button>62 <button63 style={{64 color: applyTheme.fontMode,65 backgroundColor: applyTheme.buttonHex66 }}67 className="my-button"68 >69 {this.state.bet_price}70 </button>71 <button72 style={{73 color: applyTheme.fontMode,74 backgroundColor: applyTheme.buttonHex75 }}76 className="my-button"77 >78 {this.state.winning_average}79 </button>80 <div className="sub-div">81 <button82 style={{83 color: applyTheme.fontMode,84 backgroundColor: applyTheme.buttonHex85 }}86 className="bottom-button"87 onClick={this.handleStakes}88 >89 Increase Stakes90 </button>91 <button92 style={{93 color: applyTheme.fontMode,94 backgroundColor: applyTheme.buttonHex95 }}96 className="bottom-button"97 onClick={this.handleBetPrice}98 >99 Increase Bet_Price100 </button>101 <button102 style={{103 color: applyTheme.fontMode,104 backgroundColor: applyTheme.buttonHex105 }}106 className="bottom-button"107 onClick={this.handleResetStakes}108 >109 Reset Stakes110 </button>111 <button112 style={{113 color: applyTheme.fontMode,114 backgroundColor: applyTheme.buttonHex115 }}116 className="bottom-button"117 onClick={this.handleResetBetPrice}118 >119 Reset Bet_Price120 </button>121 </div>122 </div>123 );124 }...
index.js
Source:index.js
...15import themedRippleFactory from '../ripple';16import theme from './theme.module.css';17const applyTheme = Component => themr(LIST, theme)(Component);18const ripple = themedRippleFactory({ centered: false, listItemIgnore: true });19const ThemedListItemAction = applyTheme(ListItemAction);20const ThemedListSubHeader = applyTheme(ListSubHeader);21const ThemedListItemText = applyTheme(ListItemText);22const ThemedListDivider = applyTheme(ListDivider);23const ThemedListItemContent = applyTheme(listItemContentFactory(ThemedListItemText));24const ThemedListItemActions = applyTheme(listItemActionsFactory(ThemedListItemAction));25const ThemedListItemLayout = applyTheme(26 listItemLayoutFactory(Avatar, ThemedListItemContent, ThemedListItemActions),27);28const ThemedListCheckbox = applyTheme(listCheckboxFactory(Checkbox, ThemedListItemContent));29const ThemedListItem = applyTheme(30 listItemFactory(ripple, ThemedListItemLayout, ThemedListItemContent),31);32const ThemedList = applyTheme(listFactory(ThemedListItem));33export { ThemedListItemActions as ListItemActions };34export { ThemedListItemContent as ListItemContent };35export { ThemedListItemLayout as ListItemLayout };36export { ThemedListSubHeader as ListSubHeader };37export { ThemedListItemText as ListItemText };38export { ThemedListCheckbox as ListCheckbox };39export { ThemedListDivider as ListDivider };40export { ThemedListItem as ListItem };...
darkmode.js
Source:darkmode.js
1const applytheme = document.querySelector('.mode');2applytheme.addEventListener('click', function(){3 if(applytheme.classList.contains('fa-sun')){4 applytheme.classList.remove('fa-sun');5 applytheme.classList.add('fa-moon');6 document.body.classList.add('dark')7 }8 else{9 applytheme.classList.remove('fa-moon');10 applytheme.classList.add('fa-sun');11 document.body.classList.remove('dark')12 }13})...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.applyTheme({6 });7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({4 });5 const page = await browser.newPage();6 await page.evaluate(async () => {7 const { applyTheme } = require('playwright/internal');8 await applyTheme('dark');9 });10 await page.screenshot({ path: `example.png` });11 await browser.close();12})();
Using AI Code Generation
1const path = require("path");2const {chromium} = require("playwright");3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 await page.applyTheme({7 colors: {8 },9 images: {10 "patternNoise": path.join(__dirname, "assets", "noise.png"),11 },12 });13 await page.screenshot({ path: "screenshot.png" });14 await browser.close();15})();16{ "button.background": "#ff0000" }
Using AI Code Generation
1const { chromium } = require('playwright');2const { applyTheme } = require('playwright/lib/server/chromium/crBrowser');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await applyTheme(page, {8 colors: {9 },10 });11 await page.screenshot({ path: 'example.png' });12 await browser.close();13})();14const { chromium } = require('playwright');15const { applyTheme } = require('playwright/lib/server/chromium/crBrowser');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 await applyTheme(context, {20 colors: {21 },22 });23 const page = await context.newPage();24 await page.screenshot({ path: 'example.png' });25 await browser.close();26})();27const { chromium } = require('playwright');28const { applyTheme } = require('playwright/lib/server/chromium/crBrowser');29(async () => {30 const browser = await chromium.launch();31 await applyTheme(browser, {32 colors: {33 },34 });35 const context = await browser.newContext();36 const page = await context.newPage();37 await page.screenshot({ path: 'example.png' });38 await browser.close();39})();40const { chromium } = require('playwright');41(async () => {42 const browser = await chromium.launch();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 await context.applyTheme({6 forcedColors: {7 'button-text': 'rgb(255, 0, 0)',8 'canvas': 'rgb(0, 0, 255)'9 }10 });11 const page = await context.newPage();12 await page.screenshot({ path: 'dark.png' });13 await browser.close();14})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 await context.applyTheme({ colorScheme: 'dark' });6 const page = await context.newPage();7 await page.screenshot({ path: 'dark.png' });8 await browser.close();9})();10deviceScaleFactor: Specify device scale factor (can
Using AI Code Generation
1const playwright = require('playwright');2const { applyTheme } = require('playwright/lib/server/browserContext');3const path = require('path');4(async () => {5 const browser = await playwright.chromium.launch();6 const context = await browser.newContext({7 viewport: {8 },9 });10 await applyTheme(context, path.join(__dirname, 'dark-theme.json'));11 const page = await context.newPage();12 await page.screenshot({ path: 'dark-theme.png' });13 await browser.close();14})();15{16 "colors": {17 }18}
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 await context._loadDefaultContextOptions();6 await context._loadDefaultContextAdBlocker();7 await context._loadDefaultContextUserAgent();8 await context._loadDefaultContextGeolocation();9 await context._loadDefaultContextPermissions();10 await context._loadDefaultContextColorScheme();11 await context._loadDefaultContextExtraHTTPHeaders();12 await context._loadDefaultContextOffline();13 await context._loadDefaultContextHttpCredentials();14 await context._loadDefaultContextViewport();15 await context._loadDefaultContextDeviceScaleFactor();16 await context._loadDefaultContextIsMobile();17 await context._loadDefaultContextHasTouch();18 await context._loadDefaultContextAcceptDownloads();19 await context._loadDefaultContextRecordVideo();20 await context._loadDefaultContextRecordHar();21 await context._loadDefaultContextRecordTrace();22 await context._loadDefaultContextRecordSnapshot();23 await context._loadDefaultContextStorageState();24 await context._loadDefaultContextLocale();25 await context._loadDefaultContextTimezoneId();26 await context._loadDefaultContextGeolocation();27 await context._loadDefaultContextPermissions();28 await context._loadDefaultContextColorScheme();29 await context._loadDefaultContextExtraHTTPHeaders();30 await context._loadDefaultContextOffline();31 await context._loadDefaultContextHttpCredentials();32 await context._loadDefaultContextViewport();33 await context._loadDefaultContextDeviceScaleFactor();34 await context._loadDefaultContextIsMobile();35 await context._loadDefaultContextHasTouch();36 await context._loadDefaultContextAcceptDownloads();37 await context._loadDefaultContextRecordVideo();38 await context._loadDefaultContextRecordHar();39 await context._loadDefaultContextRecordTrace();40 await context._loadDefaultContextRecordSnapshot();41 await context._loadDefaultContextStorageState();42 await context._loadDefaultContextLocale();43 await context._loadDefaultContextTimezoneId();44 await context._loadDefaultContextGeolocation();45 await context._loadDefaultContextPermissions();46 await context._loadDefaultContextColorScheme();47 await context._loadDefaultContextExtraHTTPHeaders();48 await context._loadDefaultContextOffline();49 await context._loadDefaultContextHttpCredentials();50 await context._loadDefaultContextViewport();
Using AI Code Generation
1const { applyTheme } = require('playwright/lib/protocol/chromium');2await applyTheme(theme);3const { applyTheme } = require('playwright/lib/server/chromium');4await applyTheme(theme);5const { applyTheme } = require('playwright/lib/cli/launchServer');6await applyTheme(theme);7const { applyTheme } = require('playwright/lib/test/runner');8await applyTheme(theme);9const { applyTheme } = require('playwright/test/lib/runner');10await applyTheme(theme);11const { applyTheme } = require('playwright/test/lib/reporters/base');12await applyTheme(theme);13const { applyTheme } = require('playwright/test/lib/reporters/json');14await applyTheme(theme);15const { applyTheme } = require('playwright/test/lib/reporters/list');16await applyTheme(theme);17const { applyTheme } = require('playwright/test/lib/reporters/line');18await applyTheme(theme);19const { applyTheme } = require('playwright/test/lib/reporters/minimal');20await applyTheme(theme);21const { applyTheme } = require('playwright/test/lib/reporters/progress');22await applyTheme(theme);23const { applyTheme } = require('playwright/test/lib/reporters/verbose');24await applyTheme(theme);25const { applyTheme } = require('playwright/test/lib/reporters/video');26await applyTheme(theme);27const { applyTheme } = require('playwright/test/lib/reporters/line');28await applyTheme(theme);29const { applyTheme } = require('playwright/test/lib/reporters/line');30await applyTheme(theme);
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!