{"id":14036525,"url":"https://github.com/guardian/grid-embed-demo","last_synced_at":"2025-09-11T00:35:51.460Z","repository":{"id":136991079,"uuid":"83924477","full_name":"guardian/grid-embed-demo","owner":"guardian","description":"An example of integration with Grid for image selection","archived":false,"fork":false,"pushed_at":"2022-08-30T18:14:29.000Z","size":3208,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-02-13T16:56:35.799Z","etag":null,"topics":["documentation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guardian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-03-04T21:01:18.000Z","updated_at":"2024-03-10T23:54:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"6495a81c-cfa5-49f5-93d6-12f3851e3456","html_url":"https://github.com/guardian/grid-embed-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fgrid-embed-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fgrid-embed-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fgrid-embed-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fgrid-embed-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guardian","download_url":"https://codeload.github.com/guardian/grid-embed-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240079637,"owners_count":19744725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documentation"],"created_at":"2024-08-12T03:02:00.904Z","updated_at":"2025-02-21T20:14:20.161Z","avatar_url":"https://github.com/guardian.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Grid Embed Demo\n\nAn example of how to embed [Grid](https://github.com/guardian/grid) into an application for image selection.\n\nThe example shown here is written without any frameworks and in standard ES5, demonstrating the basic technique.\n\n## Demo\n\n![demo](demo.gif)\n\n## How it works\n\nGrid uses [postMessage](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) to talk to the parent page when it has been iframed.\nIt sends a message when a crop is [created or selected](https://github.com/guardian/grid/blob/master/kahuna/public/js/main.js#L264-L296).\nThe message data represents a [crop](https://github.com/guardian/grid/blob/master/common-lib/src/main/scala/com/gu/mediaservice/model/Crop.scala#L11-L40).\n\nIn this demo, we:\n- add Grid in an iframe to the DOM when the `Pick image` button is clicked\n- add an event handler for the `message` event on the `window` object\n- in the event handler, we extract the url to the master crop and add it in an `img` to the DOM\n\n## Requirements\n\n- node\n- npm\n- nginx\n- [dev-nginx](https://github.com/guardian/dev-nginx)\n\n## Setup\n\nRun [`./script/setup`](./script/setup)\n\n## Usage\n\nOnce all setup steps are complete, run `npm start` to start a http server.\nYou can now go to [https://grid-embed-demo.local.dev-gutools.co.uk](https://grid-embed-demo.local.dev-gutools.co.uk).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguardian%2Fgrid-embed-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguardian%2Fgrid-embed-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguardian%2Fgrid-embed-demo/lists"}