Skip to content

Commit

Permalink
feat(match): new match template
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkz committed Jan 27, 2025
1 parent 01f2f0d commit 42b5aef
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-coins-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'anki-templates': minor
---

feat(match): new match template
9 changes: 6 additions & 3 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on: [push, pull_request]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry: ['mcq', 'tf', 'basic', 'mcq_10', 'match']
steps:
- uses: actions/checkout@v4
- name: Install pnpm
Expand All @@ -16,7 +19,7 @@ jobs:
node-version: '23.6'
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build --e2e
- run: pnpm run build --e2e --entry=${{matrix.entry}}

- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
Expand All @@ -25,6 +28,6 @@ jobs:
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
name: playwright-report-${{matrix.entry}}
path: playwright-report/
retention-days: 30
8 changes: 7 additions & 1 deletion build/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export const items: ConfigItem[] = [
{
key: 'entry',
len: 5,
variants: ['mcq', 'tf', 'basic', 'mcq_10'],
variants: [
'mcq',
'tf',
'basic',
'mcq_10',
'match',
] as const satisfies (keyof typeof entries)[],
},
{
key: 'locale',
Expand Down
26 changes: 26 additions & 0 deletions build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ const entries = {
},
],
}),
match: defineEntry({
fields: ['question', 'items', 'note', 'Tags'],
notes: [
{
config: {
field: 'native',
},
fields: {
question:
'This is the stem of the question. It supports various content formats in Anki, including bold, formulas, etc.',
items: '',
note: 'note',
},
},
{
config: {
field: 'markdown',
},
fields: {
question: mdQuestion,
items: '',
note: 'note',
},
},
],
}),
};

export { entries };
4 changes: 0 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export default defineConfig<TestOptions>({
name: `${build.config.name}:chromium`,
use: { ...devices['Desktop Chrome'], build },
},
{
name: `${build.config.name}:firefox`,
use: { ...devices['Desktop Firefox'], build },
},
{
name: `${build.config.name}:webkit`,
use: { ...devices['Desktop Safari'], build },
Expand Down
2 changes: 1 addition & 1 deletion src/entries/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CardShell } from '../components/card-shell';
import { CardShell } from '@/components/card-shell';
import { FIELD_ID } from '@/utils/const';
import { isFieldEmpty } from '@/utils/field';
import * as t from 'at/i18n';
Expand Down
23 changes: 23 additions & 0 deletions src/entries/match.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { CardShell } from '@/components/card-shell';
import { FIELD_ID } from '@/utils/const';
import { isFieldEmpty } from '@/utils/field';
import * as t from 'at/i18n';
import { AnkiField } from 'at/virtual/field';

export default () => {
const hasNote = !isFieldEmpty(FIELD_ID('note'));

return (
<CardShell
title={t.question}
answer={
hasNote ? (
<AnkiField
name="note"
className={'prose prose-sm dark:prose-invert'}
/>
) : null
}
/>
);
};

0 comments on commit 42b5aef

Please sign in to comment.