Skip to content

Commit

Permalink
how to render coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
catarak committed Nov 25, 2024
1 parent dd767a2 commit c1900f2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/modules/IDE/actions/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import i18next from 'i18next';
import apiClient from '../../../utils/apiClient';
import * as ActionTypes from '../../../constants';

// here, you'll need to import dispatchMessage from the dispatcher (look at actions/ide.js#startSkech() as reference)
// that function should dispatch the value of the coordinate preference that's set in the UI
function updatePreferences(formParams, dispatch) {
apiClient
.put('/preferences', formParams)
Expand Down
2 changes: 2 additions & 0 deletions client/modules/IDE/components/Preferences/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
setLinewrap
} from '../../actions/preferences';

// add the coordinatesVisible UI in here

export default function Preferences() {
const { t } = useTranslation();

Expand Down
2 changes: 2 additions & 0 deletions client/modules/IDE/reducers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const initialState = {
language: 'en-US',
autocloseBracketsQuotes: true,
autocompleteHinter: false
// add the coordinatesVisible state here, which you can reference in Preferences.jsx,
// and then import the action that dispatches the message in Preferences.jsx
};

const preferences = (state = initialState, action) => {
Expand Down
7 changes: 7 additions & 0 deletions client/modules/Preview/previewIndex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const App = () => {
const [basePath, setBasePath] = useState('');
const [textOutput, setTextOutput] = useState(false);
const [gridOutput, setGridOutput] = useState(false);
const [coordinatesVisible, setCoordinatesVisible] = useState(false);

Check warning on line 27 in client/modules/Preview/previewIndex.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

'coordinatesVisible' is assigned a value but never used

Check warning on line 27 in client/modules/Preview/previewIndex.jsx

View workflow job for this annotation

GitHub Actions / Test and lint code base

'coordinatesVisible' is assigned a value but never used
registerFrame(window.parent, getConfig('EDITOR_URL'));

function handleMessageEvent(message) {
Expand All @@ -47,6 +48,10 @@ const App = () => {
case MessageTypes.EXECUTE:
dispatchMessage(payload);
break;
case MessageTypes.COORDINATES:
// could probably just set payload to be t or f
setCoordinatesVisible(payload);
break;
default:
break;
}
Expand Down Expand Up @@ -85,4 +90,6 @@ const App = () => {
);
};

// <!-- insert component that reders coordinates here, put in same folder -->

render(<App />, document.getElementById('root'));
1 change: 1 addition & 0 deletions client/utils/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const MessageTypes = {
REGISTER: 'REGISTER',
EXECUTE: 'EXECUTE'
};
// Add a new message type (COORDIATES)

export function registerFrame(newFrame, newOrigin) {
const frameId = frameIndex;
Expand Down

0 comments on commit c1900f2

Please sign in to comment.