Skip to content

Commit

Permalink
refactor: adds auto-import support for the ui-library
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsos committed Jul 27, 2023
1 parent 9adcc03 commit 29b2699
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 29 deletions.
2 changes: 1 addition & 1 deletion assets/css/tailwind.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '@rotki/ui-library/dist/style.css';
@import '@rotki/ui-library/style.css';

@tailwind base;
@tailwind components;
Expand Down
1 change: 0 additions & 1 deletion components/NavigationMenu.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiIcon } from '@rotki/ui-library';
const { t } = useI18n();
</script>

Expand Down
1 change: 0 additions & 1 deletion components/account/home/AccountInformation.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { useVuelidate } from '@vuelidate/core';
import { required } from '@vuelidate/validators';
import { get, set } from '@vueuse/core';
Expand Down
1 change: 0 additions & 1 deletion components/account/home/ApiKeys.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { storeToRefs } from 'pinia';
import { useMainStore } from '~/store';
Expand Down
1 change: 0 additions & 1 deletion components/account/home/CancelSubscription.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { type Subscription } from '~/types';
import { useMainStore } from '~/store';
Expand Down
1 change: 0 additions & 1 deletion components/account/home/ChangePassword.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { useVuelidate } from '@vuelidate/core';
import { minLength, required, sameAs } from '@vuelidate/validators';
import { storeToRefs } from 'pinia';
Expand Down
1 change: 0 additions & 1 deletion components/account/home/DangerZone.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { storeToRefs } from 'pinia';
import { useMainStore } from '~/store';
import { type ActionResult } from '~/types/common';
Expand Down
1 change: 0 additions & 1 deletion components/account/login/LoginForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { useMainStore } from '~/store';
const props = withDefaults(defineProps<{ modal?: boolean }>(), {
Expand Down
1 change: 0 additions & 1 deletion components/account/password/PasswordForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { useVuelidate } from '@vuelidate/core';
import { email, required } from '@vuelidate/validators';
import { FetchError } from 'ofetch';
Expand Down
1 change: 0 additions & 1 deletion components/account/password/PasswordReset.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { useVuelidate } from '@vuelidate/core';
import { minLength, required, sameAs } from '@vuelidate/validators';
import { set } from '@vueuse/core';
Expand Down
1 change: 0 additions & 1 deletion components/account/signup/SignupForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import {
email,
helpers,
Expand Down
1 change: 0 additions & 1 deletion components/checkout/plan/ChangePlanDialog.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { get, set, toRefs } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { type ComputedRef } from 'vue';
Expand Down
2 changes: 0 additions & 2 deletions components/common/ButtonLink.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
defineOptions({
inheritAttrs: false,
});
Expand Down
1 change: 0 additions & 1 deletion components/download/DownloadButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
const emit = defineEmits<{ (e: 'click'): void }>();
const { t } = useI18n();
Expand Down
2 changes: 0 additions & 2 deletions components/footer/FooterIconLinks.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { RuiIcon } from '@rotki/ui-library';
const menus = [
{
title: 'Github',
Expand Down
2 changes: 0 additions & 2 deletions components/footer/PageFooter.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { RuiButton, RuiLogo } from '@rotki/ui-library';
const { t } = useI18n();
const year = new Date().getFullYear().toString();
Expand Down
1 change: 0 additions & 1 deletion components/header/PageHeader.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton, RuiIcon, RuiLogo } from '@rotki/ui-library';
import { storeToRefs } from 'pinia';
import { useMainStore } from '~/store';
const { t } = useI18n();
Expand Down
1 change: 0 additions & 1 deletion components/plans/blocks/PlanBox.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
import { get } from '@vueuse/core';
const props = defineProps<{
Expand Down
2 changes: 0 additions & 2 deletions components/plans/details/CustomPlan.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { RuiButton } from '@rotki/ui-library';
const { t } = useI18n();
const css = useCssModule();
</script>
Expand Down
1 change: 0 additions & 1 deletion error.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts" setup>
import { RuiButton } from '@rotki/ui-library';
import { get } from '@vueuse/core';
import { commonAttrs, noIndex } from '~/utils/metadata';
Expand Down
46 changes: 46 additions & 0 deletions modules/ui-library/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
addComponent,
addImports,
addPlugin,
createResolver,
defineNuxtModule,
} from '@nuxt/kit';
import * as ui from '@rotki/ui-library';

// Module options TypeScript interface definition
export interface ModuleOptions {}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: '@rotki/ui-library',
configKey: '@rotki/ui-library',
},
// Default configuration options of the Nuxt module
defaults: {},
async setup() {
const resolver = createResolver(import.meta.url);

addPlugin(resolver.resolve('./runtime/plugin'));

const imports = Object.keys(ui);
const components = imports.filter((i) => i.startsWith('Rui'));

for (const component of components) {
await addComponent({
name: component,
export: component,
filePath: '@rotki/ui-library',
});
}

const composables = imports.filter((i) => i.startsWith('use'));

for (const composable of composables) {
addImports({
name: composable,
as: composable,
from: '@rotki/ui-library',
});
}
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
RiTwitterLine,
RuiPlugin,
} from '@rotki/ui-library';
import { defineNuxtPlugin } from '#app';
import '@fontsource/roboto/latin.css';

export default defineNuxtPlugin((nuxtApp) => {
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default defineNuxtConfig({
['@pinia/nuxt', { disableVuex: true }],
'nuxt-simple-sitemap',
'nuxt-vitest',
'./modules/ui-library/module.ts',
],

i18n: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@nuxt/devtools": "0.6.7",
"@nuxtjs/i18n": "8.0.0-beta.12",
"@rotki/eslint-config": "1.1.0",
"@rotki/ui-library": "0.1.2",
"@rotki/ui-library": "0.2.0",
"@types/braintree-web": "3.75.23",
"@types/paypal-checkout-components": "4.0.5",
"@types/qrcode": "1.5.1",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

0 comments on commit 29b2699

Please sign in to comment.