Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | import React, { useCallback, useContext } from "react"; import l10n from "shared/lib/lang/l10n"; import trackerActions from "store/features/tracker/trackerActions"; import { useAppDispatch, useAppSelector } from "store/hooks"; import trackerImageUrl from "gbs-music-web/components/assets/tracker.png"; import pianoImageUrl from "gbs-music-web/components/assets/piano.png"; import trackerDarkImageUrl from "gbs-music-web/components/assets/tracker_dark.png"; import pianoDarkImageUrl from "gbs-music-web/components/assets/piano_dark.png"; import styled, { ThemeContext } from "styled-components"; interface MusicWebViewSelectProps { showLabels?: boolean; } const StyledViewSelectWrapper = styled.div` width: 100%; `; const StyledViewSelectOptions = styled.div` display: flex; width: 100%; margin-bottom: 10px; gap: 10px; `; const StyledViewButtonWrapper = styled.div` position: relative; flex-grow: 1; `; const StyledViewButton = styled.input.attrs({ type: "radio", })` width: 100%; height: 80px; margin: 0; padding: 0; border-radius: ${(props) => props.theme.borderRadius}px; -webkit-appearance: none; `; const SplashViewLabel = styled.label` position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #fff; border: 2px solid ${(props) => props.theme.colors.input.background}; border-radius: ${(props) => props.theme.borderRadius}px; -webkit-appearance: none; box-sizing: border-box; overflow: hidden; background-size: cover; ${StyledViewButton}:checked + & { border: 2px solid ${(props) => props.theme.colors.highlight}; box-shadow: 0 0 0px 2px ${(props) => props.theme.colors.highlight}; } `; const StyledViewName = styled.div` font-size: 11px; font-weight: bold; margin-bottom: 5px; `; const StyledViewDescription = styled.div` font-size: 11px; `; export const MusicWebViewSelect = ({ showLabels }: MusicWebViewSelectProps) => { const dispatch = useAppDispatch(); const view = useAppSelector((state) => state.tracker.view); const themeContext = useContext(ThemeContext); const setTrackerView = useCallback(() => { dispatch(trackerActions.setViewAndSave("tracker")); dispatch(trackerActions.setMobileOverlayView("none")); }, [dispatch]); const setRollView = useCallback(() => { dispatch(trackerActions.setViewAndSave("roll")); dispatch(trackerActions.setMobileOverlayView("none")); }, [dispatch]); return ( <StyledViewSelectWrapper> <StyledViewSelectOptions> <StyledViewButtonWrapper> <StyledViewButton id="view_roll" name="view" checked={view === "roll"} onChange={setRollView} /> <SplashViewLabel htmlFor="view_roll" title={l10n("FIELD_PIANO_ROLL")} style={{ backgroundImage: `url(${ themeContext?.type === "light" ? pianoImageUrl : pianoDarkImageUrl })`, backgroundPosition: "0% 50%", }} /> </StyledViewButtonWrapper> <StyledViewButtonWrapper> <StyledViewButton id="view_tracker" name="view" checked={view === "tracker"} onChange={setTrackerView} /> <SplashViewLabel htmlFor="view_tracker" title={l10n("FIELD_TRACKER")} style={{ backgroundImage: `url(${ themeContext?.type === "light" ? trackerImageUrl : trackerDarkImageUrl })`, backgroundPosition: "0% 0%", }} /> </StyledViewButtonWrapper> </StyledViewSelectOptions> {showLabels && ( <> <StyledViewName> {view === "roll" ? l10n("FIELD_PIANO_ROLL") : l10n("FIELD_TRACKER")} </StyledViewName> <StyledViewDescription> {view === "roll" ? l10n("FIELD_PIANO_ROLL_DESCRIPTION") : l10n("FIELD_TRACKER_DESCRIPTION")} </StyledViewDescription> </> )} </StyledViewSelectWrapper> ); }; |