Skip to content

Commit 4e090dc

Browse files
authored
Apps/nutritionfacts/background (#190)
* always use white in iframe * lint * remove legacy helper class * lint * shuffle file case 1 * case shuffle 2 * update import references * fix reference * lint * enable oxc * lint * lint * fix test * nutritionfacts@2.0.10 * case shuffle 1 * case shuffle 2 * update references * import from from ./logos to prevent circular dependency
1 parent 4a506c7 commit 4e090dc

40 files changed

Lines changed: 1906 additions & 587 deletions

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
"oxc.typeAware": true,
2727
"typescript.experimental.useTsgo": true,
2828
"vitest.disableWorkspaceWarning": true,
29-
"oxc.enable": false,
29+
"oxc.enable": true,
3030
}

apps/nutritionfacts/.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ You should use the provided components and utilities from InstUI to build your a
1010

1111
## InstUI Guidelines
1212

13-
<<instui-guidelines>>
13+
<<instui-guidelines>>

apps/nutritionfacts/.oxfmtrc.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"$schema": "../../node_modules/oxfmt/configuration_schema.json",
3-
"extends": ["../../.oxfmtrc.jsonc"]
4-
}
3+
"extends": ["../../.oxfmtrc.jsonc"],
4+
}

apps/nutritionfacts/.oxlintrc.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
"$schema": "../../node_modules/oxlint/configuration_schema.json",
3-
"extends": [
4-
"../../.oxlintrc.json"
5-
],
6-
"plugins": [
7-
"react",
8-
"react-perf",
9-
],
10-
}
3+
"extends": ["../../.oxlintrc.json"],
4+
"plugins": ["react", "react-perf"]
5+
}

apps/nutritionfacts/coverage/coverage.yml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,87 +11,87 @@ coverage:
1111
branches: 44.17%
1212
functions: 46.25%
1313
lines: 48.13%
14-
"App.tsx":
14+
"app.tsx":
1515
statements: 0%
1616
branches: 0%
1717
functions: 0%
1818
lines: 0%
19-
uncovered_line_numbers: "18-66"
20-
Components:
21-
Export:
22-
"ControlButton.tsx":
19+
uncovered_line_numbers: "11-57"
20+
assets:
21+
"Layout.ts":
22+
statements: 100%
23+
branches: 100%
24+
functions: 100%
25+
lines: 100%
26+
"Logos.tsx":
27+
statements: 100%
28+
branches: 100%
29+
functions: 100%
30+
lines: 100%
31+
"colors.ts":
32+
statements: 100%
33+
branches: 100%
34+
functions: 100%
35+
lines: 100%
36+
"consts.tsx":
37+
statements: 80%
38+
branches: 33.33%
39+
functions: 0%
40+
lines: 80%
41+
uncovered_line_numbers: "59"
42+
components:
43+
export:
44+
"controlButton.tsx":
2345
statements: 0%
2446
branches: 0%
2547
functions: 0%
2648
lines: 0%
2749
uncovered_line_numbers: "14-23"
28-
"Embed.tsx":
50+
"embed.tsx":
2951
statements: 0%
3052
branches: 0%
3153
functions: 0%
3254
lines: 0%
33-
uncovered_line_numbers: "8-68"
34-
"Link.tsx":
55+
uncovered_line_numbers: "8-67"
56+
"link.tsx":
3557
statements: 0%
3658
branches: 0%
3759
functions: 0%
3860
lines: 0%
39-
uncovered_line_numbers: "7-41"
40-
Layout:
41-
"Divider.tsx":
61+
uncovered_line_numbers: "7-40"
62+
layout:
63+
"divider.tsx":
4264
statements: 100%
4365
branches: 100%
4466
functions: 100%
4567
lines: 100%
46-
"NutritionFactsForm.tsx":
68+
"extendedNutritionFacts.tsx":
4769
statements: 0%
4870
branches: 0%
4971
functions: 0%
5072
lines: 0%
51-
uncovered_line_numbers: "16-73"
52-
"Presets.tsx":
73+
uncovered_line_numbers: "4-27"
74+
"getLayoutFromParams.ts":
5375
statements: 0%
5476
branches: 0%
5577
functions: 0%
5678
lines: 0%
57-
uncovered_line_numbers: "15-111"
58-
"extendedNutritionFacts.tsx":
79+
uncovered_line_numbers: "4-14"
80+
"nutritionFactsForm.tsx":
5981
statements: 0%
6082
branches: 0%
6183
functions: 0%
6284
lines: 0%
63-
uncovered_line_numbers: "4-32"
64-
"getLayoutFromParams.ts":
85+
uncovered_line_numbers: "16-61"
86+
"presets.tsx":
6587
statements: 0%
6688
branches: 0%
6789
functions: 0%
6890
lines: 0%
69-
uncovered_line_numbers: "4-19"
70-
"Main.tsx":
91+
uncovered_line_numbers: "13-94"
92+
"main.tsx":
7193
statements: 87.5%
7294
branches: 83.33%
7395
functions: 100%
7496
lines: 87.5%
7597
uncovered_line_numbers: "27"
76-
assets:
77-
"Layout.ts":
78-
statements: 100%
79-
branches: 100%
80-
functions: 100%
81-
lines: 100%
82-
"Logos.tsx":
83-
statements: 100%
84-
branches: 100%
85-
functions: 100%
86-
lines: 100%
87-
"colors.ts":
88-
statements: 100%
89-
branches: 100%
90-
functions: 100%
91-
lines: 100%
92-
"consts.tsx":
93-
statements: 80%
94-
branches: 33.33%
95-
functions: 0%
96-
lines: 80%
97-
uncovered_line_numbers: "65"

apps/nutritionfacts/index.html

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
<!doctype html>
22
<html lang="en">
3+
<head>
4+
<meta charset="utf8" />
5+
<link rel="icon" type="image/svg+xml" href="/IgniteAI.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta name="application-version" content="%VITE_PACKAGE_VERSION%" />
8+
<meta name="application-name" content="%VITE_PACKAGE_NAME%" />
9+
<title>IgniteAI Nutrition Facts</title>
10+
</head>
311

4-
<head>
5-
<meta charset="utf-8" />
6-
<link rel="icon" type="image/svg+xml" href="/IgniteAI.svg" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<meta name="application-version" content="%VITE_PACKAGE_VERSION%">
9-
<meta name="application-name" content="%VITE_PACKAGE_NAME%">
10-
<title>IgniteAI Nutrition Facts</title>
11-
</head>
12-
13-
<body>
14-
<div id="root"></div>
15-
<script type="module" src="/src/Main.tsx"></script>
16-
</body>
17-
18-
</html>
12+
<body>
13+
<div id="root"></div>
14+
<script type="module" src="/src/Main.tsx"></script>
15+
</body>
16+
</html>

apps/nutritionfacts/index.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@ describe("index.html", () => {
99
});
1010

1111
it("should have correct doctype", () => {
12-
// jsdom does not expose doctype, so we skip this in jsdom
12+
// Jsdom does not expose doctype, so we skip this in jsdom
1313
expect(document.documentElement.lang).toBe("en");
1414
});
1515

1616
it("should have correct meta tags", () => {
1717
const charset = document.querySelector("meta[charset]");
1818
expect(charset).not.toBeNull();
19-
expect(charset?.getAttribute("charset")).toBe("utf-8");
19+
expect(charset?.getAttribute("charset")).toBe("utf8");
2020

2121
const viewport = document.querySelector('meta[name="viewport"]');
2222
expect(viewport).not.toBeNull();
23-
expect(viewport?.getAttribute("content")).toBe(
24-
"width=device-width, initial-scale=1.0",
25-
);
23+
expect(viewport?.getAttribute("content")).toBe("width=device-width, initial-scale=1.0");
2624

2725
const version = document.querySelector('meta[name="application-version"]');
2826
expect(version).not.toBeNull();

apps/nutritionfacts/package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
{
2-
"browserslist": [
3-
"extends @instructure/browserslist-config-instui"
4-
],
5-
"dependencies": {
6-
"@instructure.ai/aiinfo": "workspace:^",
7-
"@instructure/ui": "^11.2.0",
8-
"react": "^19.2.0",
9-
"react-dom": "^19.2.0"
10-
},
11-
"devDependencies": {
12-
"@instructure.ai/shared-configs": "workspace:^"
13-
},
142
"name": "@instructure.ai/nutritionfacts",
3+
"version": "2.0.10",
154
"private": true,
165
"repository": {
17-
"directory": "apps/nutritionfacts",
186
"type": "git",
19-
"url": "https://github.com/instructure/instructure.ai"
7+
"url": "https://github.com/instructure/instructure.ai",
8+
"directory": "apps/nutritionfacts"
209
},
10+
"type": "module",
2111
"scripts": {
2212
"build": "vite build",
2313
"dev": "vite",
@@ -27,6 +17,16 @@
2717
"typecheck": "tsgo --noEmit",
2818
"update-cache": "vite-node ./scripts/updateCache.mts"
2919
},
30-
"type": "module",
31-
"version": "2.0.9"
32-
}
20+
"dependencies": {
21+
"@instructure.ai/aiinfo": "workspace:^",
22+
"@instructure/ui": "^11.2.0",
23+
"react": "^19.2.3",
24+
"react-dom": "^19.2.3"
25+
},
26+
"devDependencies": {
27+
"@instructure.ai/shared-configs": "workspace:^"
28+
},
29+
"browserslist": [
30+
"extends @instructure/browserslist-config-instui"
31+
]
32+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# @instructure.ai/nutritionfacts
2+
23
![version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Finstructure%2Finstructure.ai%2Frefs%2Fheads%2Fmain%2Fapps%2Fnutritionfacts%2Fpackage.json&query=%24.version&label=version&labelColor=%230e1721&color=%234279B6) ![coverage](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Finstructure%2Finstructure.ai%2Frefs%2Fheads%2Fmain%2Fapps%2Fnutritionfacts%2Fcoverage%2Fcoverage.yml&query=coverage.totals.total&logo=vitest&label=coverage&labelColor=%230E1721&color=%234279B6)
34

45
## IgniteAI Nutrition Facts Generator
@@ -16,10 +17,10 @@ An interactive web application for importing, viewing, and exporting Nutrition F
1617

1718
[View the tool on the web](https://instructure.ai/nutritionfacts) and select a feature to view its Nutrition Facts. You can:
1819

19-
* View the rendered Nutrition Facts
20-
* Print (Formatted nicely)
21-
* Copy an iFrame embed code to your clipboard
22-
* Copy the permalink to your clipboard
20+
- View the rendered Nutrition Facts
21+
- Print (Formatted nicely)
22+
- Copy an iFrame embed code to your clipboard
23+
- Copy the permalink to your clipboard
2324

2425
### Advanced Usage
2526

@@ -39,7 +40,7 @@ Nutrition Facts provide two primary export methods: permalink & embed.
3940

4041
##### Permalink
4142

42-
A permalink is an evergreen link to a specific feature's Nutrition Facts based on its unique id. Permalinks are structured as `ignite.ai/nutritionfacts/?id=<uid>`. When a permalink is accessed, the `uid` is used to fetch the latest revision of the Nutrition Facts and render them.
43+
A permalink is an evergreen link to a specific feature's Nutrition Facts based on its unique id. Permalinks are structured as `ignite.ai/nutritionfacts/?id=<uid>`. When a permalink is accessed, the `uid` is used to fetch the latest revision of the Nutrition Facts and render them.
4344

4445
When viewing a Nutrition Facts page a "Copy permalink" helper is displayed in the header.
4546

@@ -56,7 +57,6 @@ The "Copy embed code" generates an iFrame that is sized to fit the content witho
5657
5758
This makes outputting AI Components fairly simple, and standard.
5859

59-
6060
### Getting Started
6161

6262
> [!CAUTION]

0 commit comments

Comments
 (0)