-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add AMC Score Calculator extension #62
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"root": true, | ||
"env": { | ||
"es2020": true, | ||
"node": true | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"printWidth": 120, | ||
"singleQuote": true | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||||
{ | ||||||
"name": "amc-score-calculator", | ||||||
"title": "AMC Score Calculator", | ||||||
"description": "Calculates AMC scores for 8, 10, and 12", | ||||||
"icon": "command-icon.png", | ||||||
"author": "ryanccn", | ||||||
"license": "MIT", | ||||||
"commands": [ | ||||||
{ | ||||||
"name": "eight", | ||||||
"title": "AMC 8", | ||||||
"subtitle": "", | ||||||
"description": "Calculate AMC 8 scores", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you can provide more detailed description, something like "Get your AMC 8 score from number of correct answers" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same in other two commands |
||||||
"mode": "view" | ||||||
}, | ||||||
{ | ||||||
"name": "ten", | ||||||
"title": "AMC 10", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"subtitle": "", | ||||||
"description": "Calculate AMC 10 scores", | ||||||
"mode": "view" | ||||||
}, | ||||||
{ | ||||||
"name": "twelve", | ||||||
"title": "AMC 12", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"subtitle": "", | ||||||
"description": "Calculate AMC 12 scores", | ||||||
"mode": "view" | ||||||
} | ||||||
], | ||||||
"dependencies": { | ||||||
"@raycast/api": "^1.25.0" | ||||||
}, | ||||||
"devDependencies": { | ||||||
"@types/node": "~16.10.0", | ||||||
"@types/react": "^17.0.28", | ||||||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||||||
"@typescript-eslint/parser": "^5.0.0", | ||||||
"eslint": "^7.32.0", | ||||||
"eslint-config-prettier": "^8.3.0", | ||||||
"typescript": "^4.4.3" | ||||||
}, | ||||||
"scripts": { | ||||||
"build": "ray build -e dist", | ||||||
"dev": "ray develop" | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Generic from './generic'; | ||
|
||
export default () => { | ||
return <Generic title={'AMC 8 Score Calculator'} correctValue={1} emptyValue={0} />; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So does AMC 8 always returns the same number as number of correct answers? What's the value in this calculation? Or am I missing something? |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Form, ActionPanel, SubmitFormAction, showToast, ToastStyle, Detail, Icon } from '@raycast/api'; | ||
|
||
interface Props { | ||
title: string; | ||
correctValue: number; | ||
emptyValue: number; | ||
} | ||
interface Values { | ||
c: string; | ||
e: string; | ||
} | ||
|
||
const GenericCalculator = (props: Props) => { | ||
const handleSubmit = (values: Values) => { | ||
if (typeof values.c !== 'string' || (props.emptyValue !== 0 && typeof values.e !== 'string')) { | ||
showToast(ToastStyle.Failure, 'Bad Request', "Fields aren't strings"); | ||
return; | ||
} | ||
|
||
const c = parseInt(values.c); | ||
const e = props.emptyValue !== 0 ? parseInt(values.e) : 0; | ||
|
||
if (isNaN(c) || isNaN(e)) { | ||
showToast(ToastStyle.Failure, 'Bad Request', 'Enter numbers, please...'); | ||
return; | ||
} | ||
|
||
const score = c * props.correctValue + e * props.emptyValue; | ||
|
||
showToast(ToastStyle.Success, `Your score is ${score}`, 'Good job!'); | ||
}; | ||
|
||
return ( | ||
<Form | ||
actions={ | ||
<ActionPanel> | ||
<SubmitFormAction title="Get Score" onSubmit={handleSubmit} icon={Icon.Checkmark} /> | ||
</ActionPanel> | ||
} | ||
> | ||
<Form.TextField id="c" title="Correct" placeholder="Number of correct answers" /> | ||
{props.emptyValue !== 0 && <Form.TextField id="e" title="Empty" placeholder="Number of questions left empty" />} | ||
</Form> | ||
); | ||
}; | ||
|
||
export default GenericCalculator; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Generic from './generic'; | ||
|
||
export default () => { | ||
return <Generic title={'AMC 10 Score Calculator'} correctValue={6} emptyValue={1.5} />; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Generic from './generic'; | ||
|
||
export default () => { | ||
return <Generic title={'AMC 12 Score Calculator'} correctValue={6} emptyValue={1.5} />; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig", | ||
"display": "Node 16", | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
"lib": ["es2020"], | ||
"module": "commonjs", | ||
"target": "es2020", | ||
"strict": true, | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react-jsx" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.