Skip to content
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

feat(slots): unwrap slots in mdc #2534

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,20 @@ You must import the CSS from the `@kong/kongponents` package along with Vue.
Kongponents for Vue</a> by Kong, Inc.
on <a href="https://codepen.io">CodePen</a>.
</iframe>

## Nuxt Module

You can also install Kongponents as a [Nuxt module](https://nuxt.com/docs/guide/directory-structure/modules).

1. Follow the [package install instructions](#install)
2. Add the Kongponents module to your `nuxt.config.ts`

```typescript
export default defineNuxtConfig({
modules: ['@kong/kongponents/nuxt'],
})
```

:::warning NOTE
Several Kongponents perform their own data fetching via **axios** and **swrv** that may not be ideal in a Nuxt application, e.g. `KTableData`. We recommend not utilizing these components in your Nuxt project.
:::
62 changes: 62 additions & 0 deletions module/kongponents.nuxt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { defineNuxtModule, createResolver, addComponentsDir, useLogger /*, addComponent */ } from '@nuxt/kit'
// import { kebabCase, pascalCase } from 'scule'

export interface ModuleOptions {
// Define module options here as needed
}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'kongponents',
configKey: 'kongponents',
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
const logger = useLogger('default-portal-pages')

logger.start('Initializing Kongponents')

// let componentCount = 0

// const allComponents = [
// {
// name: 'KInput',
// filePath: resolver.resolve('../src/components/KInput/KInput.vue'),
// },
// {
// name: 'KButton',
// filePath: resolver.resolve('../src/components/KButton/KButton.vue'),
// },
// ]

// // Loop through the imported components
// for (const c of allComponents) {
// addComponent({
// name: c.name,
// filePath: c.filePath,
// global: true,
// kebabName: kebabCase(c.name),
// pascalName: pascalCase(c.name),
// })
// // Increment component count
// componentCount++
// }

// logger.success(`Globally registered ${componentCount} components`)

// 🥲 this doesn't work
addComponentsDir({
path: resolver.resolve('../src/components/'),
extensions: ['vue'],
pattern: '**/*.vue',
pathPrefix: false,
prefix: '',
global: true,
})

// TODO: Add KToggle

logger.success('Globally registered all Kongponents')
},
})
20 changes: 20 additions & 0 deletions module/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"types": [
"vite/client",
"@nuxt/schema"
],
"outDir": "../dist/nuxt",
"declarationDir": "../dist/nuxt",
},
"include": [
"**/*.ts"
],
"exclude": [
"src/**",
"sandbox",
"node_modules",
"dist",
],
}
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"module": "./dist/kongponents.es.js",
"files": [
"dist",
"src",
"bin"
],
"types": "dist/types/index.d.ts",
Expand All @@ -22,13 +23,19 @@
"require": "./dist/kongponents.umd.js",
"types": "./dist/types/index.d.ts"
},
"./nuxt": {
"import": "./dist/nuxt/kongponents-nuxt.es.js",
"require": "./dist/nuxt/kongponents-nuxt.cjs",
"types": "./dist/nuxt/kongponents.nuxt.d.ts"
},
"./package.json": "./package.json",
"./dist/*": "./dist/*"
},
"scripts": {
"build:cli": "rimraf ./bin && tsc --project ./cli/tsconfig.json && chmod u+x ./bin/index.js",
"build:docs": "vitepress build docs",
"build:kongponents": "pnpm typecheck && vite build && vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly && tsc-alias -p './tsconfig.build.json'",
"build:kongponents": "pnpm typecheck && vite build && vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly && tsc-alias -p './tsconfig.build.json' && pnpm build:nuxt:module",
"build:nuxt:module": "vue-tsc -p './module/tsconfig.json' --noEmit && vite build --config vite.config.nuxt.module.ts && vue-tsc -p './module/tsconfig.json' --emitDeclarationOnly",
"build:visualize": "cross-env-shell BUILD_VISUALIZER=true vite build -m production",
"build": "pnpm build:cli && pnpm stylelint && pnpm lint && pnpm build:kongponents && pnpm build:docs",
"build:ci": "pnpm build:kongponents && pnpm build:docs",
Expand Down Expand Up @@ -61,6 +68,7 @@
"focus-trap": "^7.6.0",
"focus-trap-vue": "^4.0.3",
"nanoid": "^5.0.9",
"scule": "^1.3.0",
"sortablejs": "^1.15.3",
"swrv": "^1.0.4",
"v-calendar": "^3.1.2",
Expand All @@ -81,6 +89,8 @@
"@kong-ui-public/sandbox-layout": "^2.1.59",
"@kong/design-tokens": "^1.17.2",
"@kong/eslint-config-kong-ui": "^1.1.2",
"@nuxt/kit": "^3.14.1592",
"@nuxt/schema": "^3.14.1592",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@stylistic/stylelint-plugin": "^3.1.1",
Expand Down
Loading
Loading