@scalar/api-reference
Version:
Generate beautiful API references from OpenAPI documents
35 lines (34 loc) • 1.25 kB
JavaScript
import { defineComponent, computed, createBlock, openBlock, resolveDynamicComponent, normalizeStyle, withCtx, renderSlot, createTextVNode, toDisplayString } from "vue";
import { getHttpMethodInfo } from "@scalar/helpers/http/http-info";
import { normalizeHttpMethod } from "@scalar/helpers/http/normalize-http-method";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "HttpMethod",
props: {
as: {},
property: {},
short: { type: Boolean },
method: {}
},
setup(__props) {
const props = __props;
const httpMethodInfo = computed(
() => getHttpMethodInfo(String(props.method || ""))
);
const normalized = computed(() => normalizeHttpMethod(props.method));
return (_ctx, _cache) => {
return openBlock(), createBlock(resolveDynamicComponent(__props.as ?? "span"), {
class: "uppercase",
style: normalizeStyle({ [__props.property || "color"]: httpMethodInfo.value.colorVar })
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default"),
createTextVNode(" " + toDisplayString(__props.short ? httpMethodInfo.value.short : normalized.value), 1)
]),
_: 3
}, 8, ["style"]);
};
}
});
export {
_sfc_main as default
};