|
| 1 | +{ |
| 2 | + "New onyx component": { |
| 3 | + "prefix": "onyx-component", |
| 4 | + "description": "Generates a boilerplate onyx Vue Component based on the filename.", |
| 5 | + "isFileTemplate": true, |
| 6 | + "scope": "vue", |
| 7 | + "body": [ |
| 8 | + "<script lang=\"ts\" setup>", |
| 9 | + "import { useDensity } from \"../../composables/density.js\";", |
| 10 | + "import type { ${TM_FILENAME_BASE}Props } from \"./types.js\";", |
| 11 | + "", |
| 12 | + "const props = defineProps<${TM_FILENAME_BASE}Props>();", |
| 13 | + "", |
| 14 | + "const { densityClass } = useDensity(props);", |
| 15 | + "</script>", |
| 16 | + "", |
| 17 | + "<template>", |
| 18 | + " <div :class=\"['onyx-component', '${TM_FILENAME_BASE/^([A-Z])|([a-z])([A-Z])/${1:/downcase}$2${3:+-}${3:/downcase}/g}', densityClass]\">", |
| 19 | + " ${1:<!-- add component content here... -->}", |
| 20 | + " </div>", |
| 21 | + "</template>", |
| 22 | + "", |
| 23 | + "<style lang=\"scss\">", |
| 24 | + "@use \"../../styles/mixins/layers.scss\";", |
| 25 | + "", |
| 26 | + ".${TM_FILENAME_BASE/^([A-Z])|([a-z])([A-Z])/${1:/downcase}$2${3:+-}${3:/downcase}/g} {", |
| 27 | + " @include layers.component() {", |
| 28 | + " // add component styles here...", |
| 29 | + " }", |
| 30 | + "}", |
| 31 | + "</style>", |
| 32 | + "", |
| 33 | + ], |
| 34 | + }, |
| 35 | + "New onyx component properties": { |
| 36 | + "prefix": "onyx-component-props", |
| 37 | + "description": "Generates the property type definition for a new onyx component based on the parent folder name.", |
| 38 | + "include": ["types.ts"], |
| 39 | + "scope": "typescript", |
| 40 | + "body": [ |
| 41 | + "import type { DensityProp } from \"../../composables/density.js\";", |
| 42 | + "", |
| 43 | + "export type ${TM_DIRECTORY/.*[\\\\\\/](.*)$/$1/}Props = DensityProp & {", |
| 44 | + " $1", |
| 45 | + "};", |
| 46 | + "", |
| 47 | + ], |
| 48 | + }, |
| 49 | + "New onyx Storybook file": { |
| 50 | + "prefix": "onyx-component-storybook", |
| 51 | + "description": "Generates a boilerplate onyx Storybook file based on the filename.", |
| 52 | + "isFileTemplate": true, |
| 53 | + "scope": "typescript", |
| 54 | + "include": ["*.stories.ts"], |
| 55 | + "body": [ |
| 56 | + "import type { Meta, StoryObj } from \"@storybook/vue3-vite\";", |
| 57 | + "import ${TM_FILENAME_BASE/\\.stories$//} from \"./${TM_FILENAME_BASE/\\.stories$//}.vue\";", |
| 58 | + "", |
| 59 | + "const meta: Meta<typeof ${TM_FILENAME_BASE/\\.stories$//}> = {", |
| 60 | + " title: \"${1:Support}/${TM_FILENAME_BASE/^Onyx(.*)\\.stories$/$1/}\",", |
| 61 | + " component: ${TM_FILENAME_BASE/\\.stories$//},", |
| 62 | + "};", |
| 63 | + "", |
| 64 | + "export default meta;", |
| 65 | + "type Story = StoryObj<typeof ${TM_FILENAME_BASE/\\.stories$//}>;", |
| 66 | + "", |
| 67 | + "export const Default = {", |
| 68 | + " args: {", |
| 69 | + " ${2:// properties here...}", |
| 70 | + " },", |
| 71 | + "} satisfies Story;", |
| 72 | + "", |
| 73 | + ], |
| 74 | + }, |
| 75 | + "New onyx Playwright test": { |
| 76 | + "prefix": "onyx-component-playwright", |
| 77 | + "description": "Generates a boilerplate onyx Playwright screenshot test file based on the filename.", |
| 78 | + "scope": "typescriptreact", |
| 79 | + "include": ["*.ct.tsx"], |
| 80 | + "body": [ |
| 81 | + "import { useFocusStateHooks } from \"@sit-onyx/playwright-utils\";", |
| 82 | + "import { DENSITIES } from \"../../composables/density.js\";", |
| 83 | + "import { test } from \"../../playwright/a11y.js\";", |
| 84 | + "import { executeMatrixScreenshotTest } from \"../../playwright/screenshots.js\";", |
| 85 | + "import ${TM_FILENAME_BASE/\\.ct$//} from \"./${TM_FILENAME_BASE/\\.ct$//}.vue\";", |
| 86 | + "", |
| 87 | + "test.describe(\"Screenshot tests\", () => {", |
| 88 | + " executeMatrixScreenshotTest({", |
| 89 | + " name: \"${TM_FILENAME_BASE/\\.ct$//}\",", |
| 90 | + " columns: DENSITIES,", |
| 91 | + " rows: [\"default\", \"hover\", \"focus-visible\", \"active\"],", |
| 92 | + " component: (column) => <${TM_FILENAME_BASE/\\.ct$//} density={column} />,", |
| 93 | + " hooks: {", |
| 94 | + " beforeEach: async (component, page, column, row) => {", |
| 95 | + " await useFocusStateHooks({ component, page, state: row });", |
| 96 | + " },", |
| 97 | + " },", |
| 98 | + " });", |
| 99 | + "});", |
| 100 | + "", |
| 101 | + ], |
| 102 | + }, |
| 103 | +} |
0 commit comments