Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #275 from microsoft/users/t-xunguy/sensors-placeho…
Browse files Browse the repository at this point in the history
…lder

Place holder for Sensors that are not implemented
  • Loading branch information
xnkevinnguyen committed Mar 23, 2020
2 parents 0607c1e + ca68a7f commit 918093c
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/view/components/microbit/Microbit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,16 @@ const MICROBIT_TOOLBAR_BUTTONS: Array<{ label: string; image: JSX.Element }> = [
image: TOOLBAR_SVG.MOTION_SVG,
label: MICROBIT_TOOLBAR_ID.ACCELEROMETER,
},
{
image: TOOLBAR_SVG.GPIO_SVG,
label: MICROBIT_TOOLBAR_ID.GPIO,
},
{
image: TOOLBAR_SVG.SPEAKER_SVG,
label: MICROBIT_TOOLBAR_ID.SOUND,
},
{
image: TOOLBAR_SVG.WIRELESS_SVG,
label: MICROBIT_TOOLBAR_ID.WIRELESS,
},
];
173 changes: 173 additions & 0 deletions src/view/components/microbit/__snapshots__/Microbit.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2968,6 +2968,179 @@ Array [
</svg>
</button>
</div>
<div
className="ms-TooltipHost root-49"
onBlurCapture={[Function]}
onFocusCapture={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<button
aria-label="toolbar gpio"
className="toolbar-button button"
id="toolbar-gpio-button"
onClick={[Function]}
role="button"
style={
Object {
"width": 32,
}
}
tabIndex={0}
>
<svg
height="16px"
version="1.1"
viewBox="0 0 18 16"
width="18px"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<title>
GPIO
</title>
<desc>
Created with Sketch.
</desc>
<g
fill="none"
fill-rule="evenodd"
id="GPIO"
stroke="none"
stroke-width="1"
>
<g
className="button-icon"
id="Group-10"
transform="translate(0.000000, 5.000000)"
>
<path
d="M4.80046857,3.47534517 C4.80046857,5.04142012 3.93244826,6 2.49863335,6 C0.938305349,6 0,4.8678501 0,2.99408284 C0,1.14398422 0.941819602,0 2.46349082,0 C3.70050761,0 4.6212417,0.808678501 4.74775478,2.01183432 L3.47559547,2.01183432 C3.34908239,1.51084813 2.96954315,1.20710059 2.46349082,1.20710059 C1.74306911,1.20710059 1.31433034,1.86982249 1.31433034,2.97830375 C1.31433034,4.10650888 1.78875439,4.79289941 2.52674736,4.79289941 C3.11362749,4.79289941 3.52128075,4.40631164 3.55290902,3.83037475 L3.55642327,3.7357002 L2.62866068,3.7357002 L2.62866068,2.74161736 L4.80046857,2.74161736 L4.80046857,3.47534517 Z M5.76337368,0.153846154 L7.9843811,0.153846154 C9.0737993,0.153846154 9.81179227,0.950690335 9.81179227,2.17357002 C9.81179227,3.38461538 9.03514252,4.17751479 7.90706755,4.17751479 L7.05310426,4.17751479 L7.05310426,5.84615385 L5.76337368,5.84615385 L5.76337368,0.153846154 Z M7.05310426,1.26627219 L7.05310426,3.08481262 L7.63647013,3.08481262 C8.18469348,3.08481262 8.50800469,2.76923077 8.50800469,2.17751479 C8.50800469,1.57790927 8.18820773,1.26627219 7.64349863,1.26627219 L7.05310426,1.26627219 Z M12.0468567,5.84615385 L10.7571261,5.84615385 L10.7571261,0.153846154 L12.0468567,0.153846154 L12.0468567,5.84615385 Z M15.5048809,0 C17.0300664,0 18,1.14792899 18,2.99802761 C18,4.85207101 17.0300664,6 15.5048809,6 C13.9726669,6 13.0027333,4.85207101 13.0027333,2.99802761 C13.0027333,1.14792899 13.9832097,0 15.5048809,0 Z M15.5048809,1.19921105 C14.7914877,1.19921105 14.3170636,1.90138067 14.3170636,2.99802761 C14.3170636,4.09861933 14.7844592,4.80078895 15.5048809,4.80078895 C16.2182741,4.80078895 16.6891839,4.09861933 16.6891839,2.99802761 C16.6891839,1.90138067 16.2147599,1.19921105 15.5048809,1.19921105 Z"
id="GPIO"
/>
</g>
</g>
</svg>
</button>
</div>
<div
className="ms-TooltipHost root-49"
onBlurCapture={[Function]}
onFocusCapture={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<button
aria-label="toolbar microbit-sound"
className="toolbar-button button"
id="toolbar-microbit-sound-button"
onClick={[Function]}
role="button"
style={
Object {
"width": 32,
}
}
tabIndex={0}
>
<svg
height="16px"
version="1.1"
viewBox="0 0 16 16"
width="16px"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<title>
Speaker
</title>
<desc>
Created with Sketch.
</desc>
<g
fill="none"
fill-rule="evenodd"
id="speaker"
stroke="none"
stroke-width="1"
>
<g
className="button-icon"
id="Group-10"
transform="translate(1.000000, 1.000000)"
>
<g
id="sound"
>
<path
d="M0,4.46138 C0,4.35093 0.089543,4.26138 0.2,4.26138 L3.35989,4.26138 C3.41494,4.26138 3.46756,4.23869 3.50534,4.19866 L7.40837,0.0631292 C7.53259,-0.0684915 7.75382,0.0194193 7.75382,0.200402 L7.75382,13.7995 C7.75382,13.9805 7.53259,14.0684 7.40837,13.9368 L3.50534,9.80125 C3.46756,9.76122 3.41494,9.73853 3.35989,9.73853 L0.2,9.73853 C0.0895431,9.73853 0,9.64898 0,9.53853 L0,4.46138 Z M9.47694,1.2485 C9.47694,1.11913 9.59801,1.02371 9.72228,1.05971 C12.189,1.77423 14,4.16201 14,6.99903 C14,9.83605 12.189,12.2238 9.72228,12.9384 C9.59801,12.9743 9.47694,12.8789 9.47694,12.7496 L9.47694,12.0651 C9.47694,11.9778 9.53367,11.9011 9.61583,11.8716 C11.4213,11.2241 12.9096,9.1562 12.9096,7.03991 C12.9096,4.92363 11.4213,2.85576 9.61583,2.20821 C9.53367,2.17874 9.47694,2.10205 9.47694,2.01476 L9.47694,1.2485 Z"
id="Shape"
/>
</g>
</g>
</g>
</svg>
</button>
</div>
<div
className="ms-TooltipHost root-49"
onBlurCapture={[Function]}
onFocusCapture={[Function]}
onKeyDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<button
aria-label="toolbar microbit-wireless"
className="toolbar-button button"
id="toolbar-microbit-wireless-button"
onClick={[Function]}
role="button"
style={
Object {
"width": 32,
}
}
tabIndex={0}
>
<svg
height="16px"
version="1.1"
viewBox="0 0 250 300"
width="16px"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<title>
Bluetooth and Radio
</title>
<g
className="button-icon"
fill="none"
fill-rule="evenodd"
id="wireless"
>
<path
d="M140,74.584c-17.391,0-31.539,14.148-31.539,31.539c0,13.896,9.037,25.712,21.539,29.905v132.69c0,5.523,4.477,10,10,10 s10-4.477,10-10v-132.69c12.502-4.192,21.539-16.009,21.539-29.905C171.539,88.732,157.391,74.584,140,74.584z"
/>
<path
d="M194.458,36.066c-4.705-2.888-10.863-1.416-13.754,3.29c-2.89,4.707-1.416,10.865,3.291,13.754 c18.594,11.415,29.694,31.232,29.694,53.013c0.002,21.778-11.1,41.595-29.694,53.011c-4.707,2.89-6.181,9.047-3.291,13.754 c1.888,3.075,5.17,4.77,8.532,4.77c1.783,0,3.59-0.477,5.222-1.479c24.567-15.082,39.233-41.271,39.232-70.057 C233.689,77.336,219.023,51.147,194.458,36.066z"
/>
<path
d="M228.532,3.283c-4.418-3.314-10.686-2.416-14,2.001c-3.313,4.418-2.417,10.686,2.002,14 C244.157,39.996,260,71.648,260,106.123c0,34.474-15.843,66.126-43.466,86.839c-4.419,3.313-5.314,9.581-2.002,13.999 c1.965,2.62,4.968,4.001,8.009,4.001c2.087,0,4.192-0.651,5.991-2C261.241,184.437,280,146.953,280,106.123 C280,65.292,261.24,27.808,228.532,3.283z"
/>
<path
d="M96.005,53.111c4.707-2.89,6.181-9.047,3.291-13.754c-2.889-4.705-9.044-6.18-13.754-3.29 c-24.565,15.081-39.231,41.27-39.231,70.056c-0.002,28.786,14.664,54.976,39.231,70.058c1.632,1.001,3.438,1.479,5.222,1.479 c3.361,0,6.645-1.695,8.532-4.77c2.89-4.707,1.416-10.865-3.291-13.754c-18.595-11.416-29.696-31.233-29.694-53.012 C66.311,84.343,77.411,64.526,96.005,53.111z"
/>
<path
d="M63.468,192.962C35.845,172.251,20.002,140.599,20,106.124c0.002-34.477,15.845-66.129,43.466-86.84 c4.419-3.313,5.314-9.581,2.002-14c-3.314-4.419-9.581-5.316-14-2.001C18.762,27.806,0.002,65.29,0,106.124 c0.002,40.832,18.762,78.316,51.47,102.84c1.799,1.349,3.903,1.999,5.991,1.999c3.041,0,6.044-1.382,8.009-4.001 C68.782,202.543,67.887,196.275,63.468,192.962z"
/>
</g>
</svg>
</button>
</div>
</div>
</div>
</div>,
Expand Down
49 changes: 49 additions & 0 deletions src/view/components/toolbar/SensorModalUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const TOOLBAR_ICON_LABEL = {
TAG_INPUT: "Tag Input",
TAG_OUTPUT: "Tag Output",
TEMPERATURE: "Temperature Sensor",
WIRELESS: "Bluetooth and Radio",
};
export const CPX_TOOLBAR_ICON_ID = {
GPIO: "toolbar-gpio",
Expand All @@ -68,6 +69,9 @@ export const MICROBIT_TOOLBAR_ID = {
ACCELEROMETER: "toolbar-accelerometer-sensor",
LEDS: "toolbar-microbit-led",
PUSH_BUTTON: "toolbar-microbit-button",
GPIO: "toolbar-gpio",
SOUND: "toolbar-microbit-sound",
WIRELESS: "toolbar-microbit-wireless",
};

export interface IModalContent {
Expand Down Expand Up @@ -321,6 +325,48 @@ export const MICROBIT_BUTTON_CONTENT = (
id: "microbit_button",
};
};
export const MICROBIT_SOUND_MODAL_CONTENT = (
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
sensorValues: { [key: string]: number }
): IModalContent => {
return {
descriptionTitle: "toolbar-microbit-sound.title",
tagInput: undefined,
tagOutput: TAG_OUTPUT_SVG,
descriptionText: "toolbar-microbit-sound.description",
tryItDescription: "toolbar-microbit-sound.tryItDescription",
components: [FEATURE_REQUEST_ON_GITHUB],
id: "microbit_sound",
};
};
export const MICROBIT_GPIO_MODAL_CONTENT = (
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
sensorValues: { [key: string]: number }
): IModalContent => {
return {
descriptionTitle: "toolbar-microbit-gpio.title",
tagInput: TAG_INPUT_SVG,
tagOutput: TAG_OUTPUT_SVG,
descriptionText: "toolbar-microbit-gpio.description",
tryItDescription: "toolbar-microbit-gpio.tryItDescription",
components: [FEATURE_REQUEST_ON_GITHUB],
id: "microbit_gpio",
};
};
export const MICROBIT_WIRELESS_MODAL_CONTENT = (
onUpdateValue: (sensor: SENSOR_LIST, value: number) => void,
sensorValues: { [key: string]: number }
): IModalContent => {
return {
descriptionTitle: "toolbar-microbit-wireless.title",
tagInput: TAG_INPUT_SVG,
tagOutput: TAG_OUTPUT_SVG,
descriptionText: "toolbar-microbit-wireless.description",
tryItDescription: "toolbar-microbit-wireless.tryItDescription",
components: [FEATURE_REQUEST_ON_GITHUB],
id: "microbit_wireless",
};
};

export const LABEL_TO_MODAL_CONTENT_CONSTRUCTOR = new Map([
[CPX_TOOLBAR_ICON_ID.GPIO, GPIO_MODAL_CONTENT],
Expand All @@ -337,6 +383,9 @@ export const LABEL_TO_MODAL_CONTENT_CONSTRUCTOR = new Map([
[MICROBIT_TOOLBAR_ID.ACCELEROMETER, ACCELEROMETER_MODAL_CONTENT],
[MICROBIT_TOOLBAR_ID.LEDS, MICROBIT_LED_CONTENT],
[MICROBIT_TOOLBAR_ID.PUSH_BUTTON, MICROBIT_BUTTON_CONTENT],
[MICROBIT_TOOLBAR_ID.GPIO, MICROBIT_GPIO_MODAL_CONTENT],
[MICROBIT_TOOLBAR_ID.SOUND, MICROBIT_SOUND_MODAL_CONTENT],
[MICROBIT_TOOLBAR_ID.WIRELESS, MICROBIT_WIRELESS_MODAL_CONTENT],
]);

export const getModalContent = (
Expand Down
Loading

0 comments on commit 918093c

Please sign in to comment.