. */ namespace Fisharebest\Webtrees; /** * Helper functions to generate markup for FontAwesome. * * @link http://fontawesome.io/accessibility */ class FontAwesome extends Html { /** Which font-awesome icon to use for which action/entity */ const ICONS = [ // Application icons 'add' => 'fa fa-plus wt-icon-add', 'calendar' => 'fa fa-calendar wt-icon-calendar', 'cancel' => 'fa fa-close wt-icon-cancel', 'coordinates' => 'fa fa-map-marker wt-icon-coordinates', 'copy' => 'fa fa-copy wt-icon-copy', 'delete' => 'fa fa-trash-o wt-icon-delete', 'download' => 'fa fa-download wt-icon-download', 'edit' => 'fa fa-pencil wt-icon-edit', 'help' => 'fa fa-info-circle wt-icon-help', 'email' => 'fa fa-envelope-o wt-icon-email', 'keyboard' => 'fa fa-keyboard-o wt-icon-keyboard', 'pin' => 'fa fa-thumb-tack wt-icon-pin', 'preferences' => 'fa fa-wrench wt-icon-preferences', 'save' => 'fa fa-check wt-icon-save', 'warning' => 'fa fa-warning wt-icon-warning', // Arrows (start/end variants require fontawesome-rtl library) 'arrow-down' => 'fa fa-arrow-down wt-icon-arrow-down', 'arrow-end' => 'fa fa-arrow-end wt-icon-arrow-end', 'arrow-start' => 'fa fa-arrow-start wt-icon-arrow-start', 'arrow-up' => 'fa fa-arrow-up wt-icon-arrow-up', // GEDCOM records 'family' => 'fa fa-users wt-icon-family', 'individual' => 'fa fa-user wt-icon-individual', 'note' => 'fa fa-sticky-note-o wt-icon-note', 'media' => 'fa fa-file-imate-o wt-icon-media', 'repository' => 'fa fa-institution wt-icon-repository', 'source' => 'fa fa-file-text-o wt-icon-source', 'submitter' => 'fa fa-user-o wt-icon-submitter', 'upload' => 'fa fa-upload wt-icon-upload', // External sites and applications 'bing-maps' => 'fa fa-icon-map-o wt-icon-bing-maps', 'google-maps' => 'fa fa-icon-map-o wt-icon-google-maps', 'openstreetmap' => 'fa fa-icon-map-o wt-icon-openstreetmap', ]; /** * Generate a decorative icon. * * These icons are shown in addition to other text, and should be ignored * by assistive technology. * * @param string $icon The icon to show * @param string[] $attributes Additional HTML attributes * * @return string */ public static function decorativeIcon($icon, $attributes = []) { $attributes['class'] = self::ICONS[$icon]; $attributes['aria-hidden'] = 'true'; return ''; } /** * Generate a semantic icon. * * These icons convey meaning, such as status/type/mode, and need * to allow assistive technology to display this meaning. * * @param string $icon The icon to show * @param string $title The meaning of the icon * @param string[] $attributes Additional HTML attributes * * @return string */ public static function semanticIcon($icon, $title, $attributes = []) { $attributes['title'] = $title; return self::decorativeIcon($icon, $attributes) . '' . $title . ''; } /** * Generate a link icon. * * @param string $icon The icon to show * @param string $title The meaning of the icon * @param string[] $attributes Additional HTML attributes * * @return string */ public static function linkIcon($icon, $title, $attributes = []) { $attributes['aria-label'] = strip_tags($title); return '' . self::decorativeIcon($icon, ['title' => $title]) . ''; } }