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

Commit

Permalink
Add tooltip for sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
xnkevinnguyen committed Feb 20, 2020
1 parent 4a7bea5 commit 836131a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/view/components/toolbar/SensorModalUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const CPX_TOOLBAR_ICON_ID = {
export const MICROBIT_TOOLBAR_ID = {
TEMPERATURE: "toolbar-temperature-sensor",
LIGHT: "toolbar-light-sensor",
ACCELEROMETER: "toolbar-accelerometer",
ACCELEROMETER: "toolbar-accelerometer-sensor",
LEDS: "toolbar-microbit-led",
PUSH_BUTTON: "toolbar-microbit-button",
};
Expand Down
43 changes: 27 additions & 16 deletions src/view/components/toolbar/ToolBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
IModalContent,
LABEL_TO_MODAL_CONTENT,
} from "./SensorModalUtils";
import { TooltipHost } from 'office-ui-fabric-react/lib/Tooltip';


interface IToolbarState {
currentOpenedId: string;
Expand All @@ -26,6 +28,7 @@ interface IProps extends WrappedComponentProps {
}>;
}


class ToolBar extends React.Component<IProps, IToolbarState, any> {
private readonly TOOLBAR_BUTTON_WIDTH: number = 32;

Expand All @@ -46,22 +49,30 @@ class ToolBar extends React.Component<IProps, IToolbarState, any> {
{buttonList.map(
(currrentButton: any, index: number) => {
return (
<Button
key={index}
label={currrentButton.label}
width={this.TOOLBAR_BUTTON_WIDTH}
onClick={(
e: React.MouseEvent<HTMLElement>
) => {
this.handleOnClick(
e,
currrentButton.label
);
}}
image={currrentButton.image}
styleLabel="toolbar"
focusable={true}
/>
<TooltipHost tooltipProps={
{
onRenderContent: () => (
<FormattedMessage id={`${currrentButton.label}.title`} />

)
}
} key={index}> <Button
key={index}
label={currrentButton.label}
width={this.TOOLBAR_BUTTON_WIDTH}
onClick={(
e: React.MouseEvent<HTMLElement>
) => {
this.handleOnClick(
e,
currrentButton.label
);
}}
image={currrentButton.image}
styleLabel="toolbar"
focusable={true}
/></TooltipHost>

);
}
)}
Expand Down
2 changes: 1 addition & 1 deletion src/view/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"toolbar-microbit-button.title": "Buttons",
"toolbar-microbit-button.description": "There are two buttons on the front of the micro:bit (labelled A and B). The third button is to trigger both A and B buttons. You can detect when these buttons are pressed, allowing you to trigger code on the device.",
"toolbar-microbit-button.tryItDescription": "Click them with your mouse. Pressing “A” “B” on your keyboard will be implemented soon!"
}
}

0 comments on commit 836131a

Please sign in to comment.