Skip to content

Commit

Permalink
POC: Start using Codex
Browse files Browse the repository at this point in the history
I thought the TextInput would be an easy component to start with. I was
wrong, but hey, at least this mostly works. I also left some TODOs in
the code as a treat.

Bug: T369505
  • Loading branch information
lucaswerkmeister committed Sep 9, 2024
1 parent 8396f13 commit 5d80288
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 19 deletions.
137 changes: 137 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"node": ">=16"
},
"dependencies": {
"@wikimedia/codex": "^1.12.0",
"@wmde/wikibase-datamodel-types": "^0.2.0",
"@wmde/wikit-tokens": "^3.0.0-alpha.12",
"@wmde/wikit-vue-components": "^3.0.0-alpha.12",
Expand Down
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AnonymousEditWarning from '@/components/AnonymousEditWarning.vue';
import NewLexemeForm from '@/components/NewLexemeForm.vue';
import SearchExisting from '@/components/SearchExisting.vue';
import '@wmde/wikit-vue-components/dist/wikit-vue-components.css';
import '@wikimedia/codex/dist/codex.style.css';
</script>

Expand Down
45 changes: 27 additions & 18 deletions src/components/LemmaInput.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { TextInput } from '@wmde/wikit-vue-components';
import RequiredAsterisk from '@/components/RequiredAsterisk.vue';
import { CdxField, CdxTextInput } from '@wikimedia/codex';
import RequiredAsterisk from '@/components/RequiredAsterisk.vue'; // eslint-disable-line @typescript-eslint/no-unused-vars
import { useMessages } from '@/plugins/MessagesPlugin/Messages';
import { useConfig } from '@/plugins/ConfigPlugin/Config';
import { useStore } from 'vuex';
Expand Down Expand Up @@ -51,23 +51,32 @@ export default {
</script>

<template>
<text-input
class="wbl-snl-lemma-input"
:label="messages.getUnescaped( 'wikibaselexeme-newlexeme-lemma' )"
:placeholder="messages.getUnescaped(
'wikibaselexeme-newlexeme-lemma-placeholder-with-example',
exampleLemma
)"
name="lemma"
aria-required="true"
:error="error"
:value="modelValue"
@input="$emit( 'update:modelValue', $event )"
<!-- TODO should :status and :messages be separate computeds? -->
<cdx-field
:status="error !== null ? 'error' : 'default'"
:messages="error !== null ? { error: error.message } : {}"
>
<template #suffix>
<required-asterisk />
</template>
</text-input>
<!-- TODO check escaping of :placeholder -->
<cdx-text-input
class="wbl-snl-lemma-input"
:placeholder="messages.getUnescaped(
'wikibaselexeme-newlexeme-lemma-placeholder-with-example',
exampleLemma
)"
name="lemma"
aria-required="true"
:model-value="modelValue"
@update:modelValue="$emit( 'update:modelValue', $event )"

Check warning on line 69 in src/components/LemmaInput.vue

View workflow job for this annotation

GitHub Actions / code-quality

v-on event '@update:modelValue' must be hyphenated
>
<!-- TODO codex docs say don’t mark required labels with an asterisk…
<template #suffix>
<required-asterisk />
</template>
-->
</cdx-text-input>
<template #label>{{ messages.getUnescaped( 'wikibaselexeme-newlexeme-lemma' ) }}</template><!-- TODO check escaping -->

Check warning on line 77 in src/components/LemmaInput.vue

View workflow job for this annotation

GitHub Actions / code-quality

This line has a length of 127. Maximum allowed is 100

Check warning on line 77 in src/components/LemmaInput.vue

View workflow job for this annotation

GitHub Actions / code-quality

Expected 1 line break after opening tag (`<template>`), but no line breaks found

Check warning on line 77 in src/components/LemmaInput.vue

View workflow job for this annotation

GitHub Actions / code-quality

Expected 1 line break before closing tag (`</template>`), but no line breaks found
</cdx-field>

Check warning on line 78 in src/components/LemmaInput.vue

View workflow job for this annotation

GitHub Actions / code-quality

Expected 1 line break before closing tag (`</template>`), but 2 line breaks found

</template>

<style lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getBuildConfig( isAppBuild: boolean ): BuildOptions {
formats: [ 'cjs' ],
},
rollupOptions: {
external: [ 'vue', 'vuex' ],
external: [ 'vue', 'vuex', '@wikimedia/codex' ],
},
};
}
Expand Down

0 comments on commit 5d80288

Please sign in to comment.