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

Syntax Highlighting, Example Hello World policy #67

Merged
merged 21 commits into from
Apr 29, 2021
Merged

Conversation

pickjasmine
Copy link
Contributor

Closes #65

  • Adds syntax highlighting to wherever code is shown, including the text field that you type your rego policy code into.
  • Adds an example policy that gets auto-populated to the create policy form.

some things to note with the addition of syntax highlighting...

The highlighter sometimes takes a moment to show the colors (viewing the occurrence JSON ,for example). I have added this to an issue to address later since it's not really breaking any functionality, it's just a weird experience.

With the change in to highlight code, the policy playground now shows the entire rego policy code, which is not a good experience if you have a lengthy policy. I plan on addressing this issue in my next PR.

The prism.js file included this PR is the code to do syntax highlighting. There is an npm package for Prism, but the latest release does not include the ability to parse rego. Once a new release of Prism and the babel plugin are cut, we can switch over to pulling down those dependencies instead of including them directly. The file is small and the parsing shouldn't change so not a huge deal, in my opinion. I have ignored the Prism file for linting and coverage.

prism/LICENSE Outdated Show resolved Hide resolved
Copy link
Contributor

@alexashley alexashley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the light theme, the text contrast with a background is a little difficult to read IMO

Screen Shot 2021-04-28 at 4 30 31 PM

Otherwise, LGTM, just had a few questions

test/components/Code.spec.js Outdated Show resolved Hide resolved
components/Code.js Outdated Show resolved Hide resolved
prism/prism.js Outdated Show resolved Hide resolved
@pickjasmine
Copy link
Contributor Author

With the light theme, the text contrast with a background is a little difficult to read IMO

Screen Shot 2021-04-28 at 4 30 31 PM

Otherwise, LGTM, just had a few questions

I updated the colors for both themes a bit so now there should be a distinction between comments and regular code. Let me know if you still think the contrast is a bit too low.

@pickjasmine pickjasmine merged commit 7567b1a into main Apr 29, 2021
@pickjasmine pickjasmine deleted the rego-editor branch April 29, 2021 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rego Policy Improvements
3 participants