whitphx HF staff commited on
Commit
dde26cd
·
1 Parent(s): 76e276e
Files changed (2) hide show
  1. index.html +23 -10
  2. style.css +0 -28
index.html CHANGED
@@ -3,17 +3,30 @@
3
  <head>
4
  <meta charset="utf-8" />
5
  <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
  </head>
9
  <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  </body>
19
  </html>
 
3
  <head>
4
  <meta charset="utf-8" />
5
  <meta name="viewport" content="width=device-width" />
6
+ <title>Static Space URL sync example</title>
 
7
  </head>
8
  <body>
9
+ <label for="">
10
+ Query string
11
+ <input type="text" id="query">
12
+ </label>
13
+ <label>
14
+ Hash
15
+ <input type="text" id="hash">
16
+ </label>
17
+ <button onclick="sync()">Sync</button>
18
+
19
+ <script>
20
+ function sync() {
21
+ const queryString = document.getElementById("query").value;
22
+ const hash = document.getElementById("hash").value;
23
+
24
+ // HF Spaces' spacial message type to update the query string and the hash in the parent page URL
25
+ window.parent.postMessage({
26
+ queryString,
27
+ hash,
28
+ })
29
+ }
30
+ </script>
31
  </body>
32
  </html>
style.css DELETED
@@ -1,28 +0,0 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
- }
5
-
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
- }
10
-
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
- }
17
-
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
- }
25
-
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }