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

Bug/share link #136

Merged
merged 4 commits into from
Sep 3, 2022
Merged
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 Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Builder
FROM node:14-buster as builder
ARG jsoncrack_host
ENV NEXT_PUBLIC_JSONCRACK_HOST $jsoncrack_host
WORKDIR /src
COPY . /src
RUN yarn install --legacy-peer-deps
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</p>

<p align="center">
<img width="800" src="/public/jsoncrack-screenshot.webp" alt="preview 1" />
<img width="800" src="./public/jsoncrack-screenshot.webp" alt="preview 1" />
</p>

# JSON Crack (jsoncrack.com)
Expand Down Expand Up @@ -60,7 +60,7 @@ You can use the web version at [jsoncrack.com](https://jsoncrack.com) or also ru
A [`Dockerfile`](Dockerfile) is provided in the root of the repository.
If you want to run JSON Crack locally:

* Build a Docker image with `docker build -t jsoncrack .`
* Build a Docker image with `docker build -t jsoncrack --build-arg jsoncrack_host=localhost:8888 .`
* Run locally with `docker run -p 8888:8080 jsoncrack`
* Go to http://localhost:8888

Expand Down
6 changes: 4 additions & 2 deletions src/containers/Modals/ShareModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ const StyledContainer = styled.div`
}
`;

const jsoncrackHost = process.env.NEXT_PUBLIC_JSONCRACK_HOST || packageJson.homepage;

export const ShareModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
const json = useConfig((state) => state.json);
const [encodedJson, setEncodedJson] = React.useState("");

const embedText = `<iframe src="${packageJson.homepage}/widget?json=${encodedJson}" width="512" height="384" style="border: 2px solid #b9bbbe; border-radius: 6px;"></iframe>`;
const shareURL = `${packageJson.homepage}/editor?json=${encodedJson}`;
const embedText = `<iframe src="${jsoncrackHost}/widget?json=${encodedJson}" width="512" height="384" style="border: 2px solid #b9bbbe; border-radius: 6px;"></iframe>`;
const shareURL = `${jsoncrackHost}/editor?json=${encodedJson}`;

React.useEffect(() => {
const jsonEncode = compress(JSON.parse(json));
Expand Down