Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
v0.36.0 update

See merge request technical-study/flash_anzan_web!41
  • Loading branch information
noritakaIzumi committed Oct 4, 2023
2 parents d259b22 + 33c98fc commit c6e18de
Show file tree
Hide file tree
Showing 23 changed files with 311 additions and 134 deletions.
2 changes: 0 additions & 2 deletions lint-staged.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurora-flash",
"version": "0.35.0",
"version": "0.36.0",
"description": "フラッシュ暗算",
"type": "module",
"dependencies": {
Expand Down Expand Up @@ -44,7 +44,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"lint:eslint": "eslint --fix './**/*.{js,ts}'",
"lint:prettier": "prettier --write './**/*.{js,ts}'",
"update-version": "npm i --package-lock-only",
"update-version": "bash ./scripts/update_version",
"prepare": "husky install",
"tauri": "tauri"
},
Expand Down
37 changes: 37 additions & 0 deletions scripts/update_version
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

repo_root=$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd)

#
# Update version of files such as package.json Cargo.toml
#
function main() {
local version
version=$1

if [[ -z "$version" ]]; then
echo 'version number is not passed'
return 1
fi
if ! [[ "$version" =~ ^([0-9]+\.)+[0-9]+ ]]; then
echo 'version number is invalid'
return 1
fi

pushd "$repo_root" || return 1

# package.json, package-lock.json
sed -i -Ee 's/^(\s+"version": ")([0-9]+\.)+[0-9]+(")/\1'"$version"'\3/' package.json
npm i --package-lock-only

pushd src-tauri || return 1

# Cargo.toml, Cargo.lock
sed -i -Ee 's/^(version = ")([0-9]+\.)+[0-9]+(")/\1'"$version"'\3/' Cargo.toml
cargo generate-lockfile

popd || return 1
popd || return 1
}

main "$@"
69 changes: 47 additions & 22 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aurora-flash"
version = "0.35.0"
version = "0.36.0"
description = "フラッシュ暗算"
authors = ["Noritaka IZUMI<noritaka.izumi@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"beforeBuildCommand": "npm run build"
},
"package": {
"productName": "aurora-flash"
"productName": "Aurora Flash"
},
"tauri": {
"windows": [
Expand Down
6 changes: 3 additions & 3 deletions src/config/flashParamSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const flashParamSchema: FlashParamSchema = {
addition: {
digit: {
min: 1,
max: 8,
max: 14,
default: 1,
difficultySupportMax: 8,
},
Expand All @@ -23,13 +23,13 @@ export const flashParamSchema: FlashParamSchema = {
multiplication: {
digit1: {
min: 1,
max: 4,
max: 7,
default: 1,
difficultySupportMax: 4,
},
digit2: {
min: 1,
max: 4,
max: 7,
default: 1,
difficultySupportMax: 4,
},
Expand Down
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
<label class="form-check-label text-light" for="hide-answer">答えを表示せず正誤判定のみ行う</label>
</div>
</div>
<div id="error-message" class="d-none d-flex justify-content-start my-3 text-warning"></div>
</div>
<div class="container-fluid">
<span id="version-number" class="text-light"><%- versionNumber %></span>
Expand Down
1 change: 1 addition & 0 deletions src/js/dom/htmlElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function getHtmlElement<K extends keyof HTMLElementTagNameMap>(

export const htmlElements = {
soundExtension: getHtmlElement('select', 'sound-extension'),
errorMessage: getHtmlElement('div', 'error-message'),
}
export const headerMessage = getHtmlElement('div', 'header-message')
export const questionNumberArea = getHtmlElement('div', 'question-number-area')
Expand Down
44 changes: 44 additions & 0 deletions src/js/flash/errorMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { htmlElements } from '../dom/htmlElement.js'

const errorMessageMap = {
difficultyNotSupported: '難易度設定がサポートされていない桁数です',
} as const

type ErrorMessageMapKey = keyof typeof errorMessageMap

export class ErrorMessage {
private readonly htmlElement: HTMLDivElement
private readonly errorsActivated: { [key in ErrorMessageMapKey]: boolean } = {
difficultyNotSupported: false,
}

constructor(htmlElement: HTMLDivElement) {
this.htmlElement = htmlElement
}

private render(): void {
const messages = (Object.keys(this.errorsActivated) as ErrorMessageMapKey[])
.map((key) => {
return this.errorsActivated[key] ? errorMessageMap[key] : null
})
.filter((message) => message !== null)
if (messages.length > 0) {
this.htmlElement.classList.remove('d-none')
} else {
this.htmlElement.classList.add('d-none')
}
this.htmlElement.innerHTML = messages.join('<br>')
}

addError(key: ErrorMessageMapKey): void {
this.errorsActivated[key] = true
this.render()
}

removeError(key: ErrorMessageMapKey): void {
this.errorsActivated[key] = false
this.render()
}
}

export const errorMessage = new ErrorMessage(htmlElements.errorMessage)
Loading

0 comments on commit c6e18de

Please sign in to comment.