UNPKG

@curveball/browser

Version:

Automatic API browser generator. A middleware that turns your JSON responses into HTML if accessed by a browser.

27 lines 769 B
import * as React from 'react'; const methodLabel = { DELETE: 'Delete', GET: 'Query', PATCH: 'Update', SEARCH: 'Search', }; const titleHintGuess = { add: 'Add', delete: 'Delete', edit: 'Edit', find: 'Find', remove: 'Remove', search: 'Search', select: 'Select', }; export function Button(props) { const label = props.title || guessTitle(props.titleHint) || methodLabel[props.method] || 'Submit'; return React.createElement("button", { type: "submit", className: 'method-' + props.method.toLowerCase() }, label); } function guessTitle(titleHint) { if (!titleHint) return; const firstWord = titleHint.split(' ')[0].toLowerCase(); return titleHintGuess[firstWord]; } //# sourceMappingURL=button.js.map