Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to render coordinates #3282

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [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 @@
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 @@
);
};

// <!-- 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
Loading