source: frontend/node_modules/@svgr/babel-plugin-transform-svg-component/lib/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.default = void 0;
5
6var _util = require("./util");
7
8function defaultTemplate({
9 template
10}, opts, {
11 imports,
12 interfaces,
13 componentName,
14 props,
15 jsx,
16 exports
17}) {
18 const plugins = ['jsx'];
19
20 if (opts.typescript) {
21 plugins.push('typescript');
22 }
23
24 const typeScriptTpl = template.smart({
25 plugins
26 });
27 return typeScriptTpl.ast`${imports}
28
29${interfaces}
30
31function ${componentName}(${props}) {
32 return ${jsx};
33}
34${exports}
35 `;
36}
37
38const plugin = (api, opts) => ({
39 visitor: {
40 Program(path) {
41 const {
42 types: t
43 } = api;
44 const template = opts.template || defaultTemplate;
45 const body = template(api, opts, {
46 componentName: t.identifier(opts.state.componentName),
47 interfaces: (0, _util.getInterface)(api, opts),
48 props: (0, _util.getProps)(api, opts),
49 imports: (0, _util.getImport)(api, opts),
50 exports: (0, _util.getExport)(api, opts),
51 jsx: path.node.body[0].expression
52 });
53
54 if (Array.isArray(body)) {
55 path.node.body = body;
56 } else {
57 path.node.body = [body];
58 }
59
60 path.replaceWith(path.node);
61 }
62
63 }
64});
65
66var _default = plugin;
67exports.default = _default;
Note: See TracBrowser for help on using the repository browser.