Skip to content

Commit c1900f2

Browse files
committed
how to render coordinates
1 parent dd767a2 commit c1900f2

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

client/modules/IDE/actions/preferences.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import i18next from 'i18next';
22
import apiClient from '../../../utils/apiClient';
33
import * as ActionTypes from '../../../constants';
44

5+
// here, you'll need to import dispatchMessage from the dispatcher (look at actions/ide.js#startSkech() as reference)
6+
// that function should dispatch the value of the coordinate preference that's set in the UI
57
function updatePreferences(formParams, dispatch) {
68
apiClient
79
.put('/preferences', formParams)

client/modules/IDE/components/Preferences/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
setLinewrap
2020
} from '../../actions/preferences';
2121

22+
// add the coordinatesVisible UI in here
23+
2224
export default function Preferences() {
2325
const { t } = useTranslation();
2426

client/modules/IDE/reducers/preferences.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const initialState = {
1313
language: 'en-US',
1414
autocloseBracketsQuotes: true,
1515
autocompleteHinter: false
16+
// add the coordinatesVisible state here, which you can reference in Preferences.jsx,
17+
// and then import the action that dispatches the message in Preferences.jsx
1618
};
1719

1820
const preferences = (state = initialState, action) => {

client/modules/Preview/previewIndex.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const App = () => {
2424
const [basePath, setBasePath] = useState('');
2525
const [textOutput, setTextOutput] = useState(false);
2626
const [gridOutput, setGridOutput] = useState(false);
27+
const [coordinatesVisible, setCoordinatesVisible] = useState(false);
2728
registerFrame(window.parent, getConfig('EDITOR_URL'));
2829

2930
function handleMessageEvent(message) {
@@ -47,6 +48,10 @@ const App = () => {
4748
case MessageTypes.EXECUTE:
4849
dispatchMessage(payload);
4950
break;
51+
case MessageTypes.COORDINATES:
52+
// could probably just set payload to be t or f
53+
setCoordinatesVisible(payload);
54+
break;
5055
default:
5156
break;
5257
}
@@ -85,4 +90,6 @@ const App = () => {
8590
);
8691
};
8792

93+
// <!-- insert component that reders coordinates here, put in same folder -->
94+
8895
render(<App />, document.getElementById('root'));

client/utils/dispatcher.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const MessageTypes = {
1313
REGISTER: 'REGISTER',
1414
EXECUTE: 'EXECUTE'
1515
};
16+
// Add a new message type (COORDIATES)
1617

1718
export function registerFrame(newFrame, newOrigin) {
1819
const frameId = frameIndex;

0 commit comments

Comments
 (0)