Skip to content

Commit

Permalink
Migrate learn-german app
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirohonda committed Aug 19, 2024
1 parent ab1565c commit 5a4f29f
Show file tree
Hide file tree
Showing 51 changed files with 602 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
yarn install
- name: Build
run: |
yarn nx build-ci fe-sys-design
yarn nx build-ci learn-german
pwd
- name: Deploy to Github page
uses: JamesIves/[email protected]
with:
ACCESS_TOKEN: ${{ secrets.LERAN_GERMAN_DEPLOY_TEST }}
BRANCH: master # The branch the action should deploy to.
FOLDER: dist/apps/fe-sys-design # The folder the action should deploy.
FOLDER: dist/apps/learn-german # The folder the action should deploy.
REPOSITORY_NAME: takahirohonda/takahirohonda.github.io
TARGET_FOLDER: learn-german-test1
TARGET_FOLDER: learn-german
CLEAN: true # Automatically remove deleted files from the deploy branch
4 changes: 4 additions & 0 deletions apps/fe-sys-design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ recognition.addEventListener('result', (event) => {
}
})
```
# Favicons
Generated by https://www.favicon-generator.org/
3 changes: 3 additions & 0 deletions apps/learn-german/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@nx/js/babel"]
}
18 changes: 18 additions & 0 deletions apps/learn-german/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
8 changes: 8 additions & 0 deletions apps/learn-german/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2016"
}
}
87 changes: 87 additions & 0 deletions apps/learn-german/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Learn German App

This project was generated by using ![@nx/web](https://nx.dev/nx-api/web/documents/overview#setting-up-nxweb). `@nx/web` is for creating a web component. It can be used to create a vanilla JS project.

# Web Speech APIs

https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API

1. Speech synthesis

```ts
// first instantiate speech utterance object.
const utterance = new SpeechSynthesisUtterance()
utterance.text = 'Hola, ¿cómo estás?'
utterance.lang = 'es-AR'
utterance.rate = 1
utterance.volume = 1
utterance.pitch = 1

// then use the speechSynthesis object.
speechSynthesis.speak(utterance)
```

```ts
// function example.
function speakGerman() {
const sentence = document.getElementById('sentence')?.textContent
if (sentence) {
const utterance = new SpeechSynthesisUtterance()
utterance.lang = 'de'
utterance.text = sentence
speechSynthesis.speak(utterance)
}
}
```

2. Speech Recognition

```ts
// Function that I made to check
const matchSpeech = (targetSentence = 'Wir Suchen Dich') => {
const SpeechRecognition =
window.SpeechRecognition || window.webkitSpeechRecognition
const recognition = new SpeechRecognition()
recognition.continuous = false
recognition.lang = 'de'
recognition.start()

recognition.onresult = (event) => {
const recongnisedOutcome = event.results[0][0].transcript
// nothing is getting logged when I try to console.log event.
console.log(`checking event object: ${JSON.stringify(event.results)}`)
console.log(
`checking event object, results[0]: ${JSON.stringify(event.results[0])}`
)
console.log(
`checking event object, results[0][0]: ${JSON.stringify(event.results[0][0])}`
)
console.log(`checking the recognised outcome: ${recongnisedOutcome}`)

if (
recongnisedOutcome.toLowerCase() === targetSentence.toLowerCase().trim()
) {
sayGenau()
} else {
sayNein()
}
recognition.stop()
}

// from the web capability course slide
const recognition = new SpeechRecognition()
recognition.continuous = false
recognition.lang = 'fr-CA'
recognition.addEventListener('result', (event) => {
if ((event.type = 'result')) {
event.results.forEach((result) => {
const confidence = result.confidence * 100
const text = result.transcript
})
}
})
```
# Favicons
Generated by https://www.favicon-generator.org/
94 changes: 94 additions & 0 deletions apps/learn-german/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Learn German App</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="apple-touch-icon"
sizes="57x57"
href="/icons/apple-icon-57x57.png"
/>
<link
rel="apple-touch-icon"
sizes="60x60"
href="/icons/apple-icon-60x60.png"
/>
<link
rel="apple-touch-icon"
sizes="72x72"
href="/icons/apple-icon-72x72.png"
/>
<link
rel="apple-touch-icon"
sizes="76x76"
href="/icons/apple-icon-76x76.png"
/>
<link
rel="apple-touch-icon"
sizes="114x114"
href="/icons/apple-icon-114x114.png"
/>
<link
rel="apple-touch-icon"
sizes="120x120"
href="/icons/apple-icon-120x120.png"
/>
<link
rel="apple-touch-icon"
sizes="144x144"
href="/icons/apple-icon-144x144.png"
/>
<link
rel="apple-touch-icon"
sizes="152x152"
href="/icons/apple-icon-152x152.png"
/>
<link
rel="apple-touch-icon"
sizes="180x180"
href="/icons/apple-icon-180x180.png"
/>
<link
rel="icon"
type="image/png"
sizes="192x192"
href="/icons/android-icon-192x192.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/icons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="96x96"
href="/icons/favicon-96x96.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/icons/favicon-16x16.png"
/>
<!-- vite will add the base path-->
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<!-- for the manifest file, vite will not add the base path -->
<!-- This causes error when we do development locally -->
<link rel="manifest" href="/learn-german/manifest.json" />
</head>
<body>
<!-- this is for a web component automatically generated by Nx -->
<!-- <new-root></new-root> -->
<main class=".container">
<script type="module" src="/src/main.ts"></script>

<h1 class=".text-indigo-800">Learn German App</h1>
<ol id="list-container"></ol>
</main>
</body>
</html>
15 changes: 15 additions & 0 deletions apps/learn-german/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { join } = require('path');

// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
// option from your application's configuration (i.e. project.json).
//
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries

module.exports = {
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
},
autoprefixer: {},
},
};
21 changes: 21 additions & 0 deletions apps/learn-german/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "learn-german",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/learn-german/src",
"tags": [],
"targets": {
"dev": {
"executor": "nx:run-commands",
"options": {
"command": "yarn nx serve learn-german"
}
},
"build-ci": {
"executor": "nx:run-commands",
"options": {
"command": "export GIT_PAGE_DEPLOY=true && yarn nx build learn-german"
}
}
}
}
Binary file added apps/learn-german/public/favicon.ico
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/learn-german/public/icons/apple-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/learn-german/public/icons/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
Binary file added apps/learn-german/public/icons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/learn-german/public/icons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/learn-german/public/icons/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/learn-german/public/icons/favicon.ico
Binary file not shown.
41 changes: 41 additions & 0 deletions apps/learn-german/public/icons/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "App",
"icons": [
{
"src": "\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/learn-german/public/icons/ms-icon-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions apps/learn-german/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "Learn German App",
"short_name": "LGA",
"icons": [
{
"src": "img/android-icon-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75"
},
{
"src": "img/android-icon-48x48.png",
"sizes": "48x48",
"type": "image/png",
"density": "1.0"
},
{
"src": "img/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5"
},
{
"src": "img/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0"
},
{
"src": "img/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0"
},
{
"src": "img/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
}
],
"start_url": "/learn-german/index.html",
"scope": ".",
"display": "standalone",
"orientation": "portrait",
"background_color": "#fff",
"theme_color": "#131313",
"description": "Learn German!",
"dir": "ltr",
"lang": "en-US"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5a4f29f

Please sign in to comment.