1// Copyright (C) 2023 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import m from 'mithril'; 16import {classNames} from '../classnames'; 17 18interface FormAttrs { 19 // List of space separated class names forwarded to the icon. 20 className?: string; 21 // Remaining attributes forwarded to the underlying HTML <button>. 22 [htmlAttrs: string]: any; 23} 24 25export class Form implements m.ClassComponent<FormAttrs> { 26 view({attrs, children}: m.CVnode<FormAttrs>) { 27 const {className, ...htmlAttrs} = attrs; 28 29 const classes = classNames( 30 'pf-form', 31 className, 32 ); 33 34 return m( 35 'form.pf-form', 36 { 37 class: classes, 38 ...htmlAttrs, 39 }, 40 children, 41 ); 42 } 43} 44 45export class FormButtonBar implements m.ClassComponent<{}> { 46 view({children}: m.CVnode<{}>) { 47 return m('.pf-form-button-bar', children); 48 } 49} 50 51interface FormLabelAttrs { 52 for: string; 53 // Remaining attributes forwarded to the underlying HTML <button>. 54 [htmlAttrs: string]: any; 55} 56 57export class FormLabel implements m.ClassComponent<FormLabelAttrs> { 58 view({attrs, children}: m.CVnode<FormLabelAttrs>) { 59 return m('label.pf-form-label', attrs, children); 60 } 61} 62