Skip to content

Commit

Permalink
[PLAY-1472] Use new icons (#3648)
Browse files Browse the repository at this point in the history
**What does this PR do?** A clear and concise description with your
runway ticket url.

We are updating some of the icons in the icon repo and also hard coding
SVGs into playbook dist so our kits can work without an icon repo

Runway https://runway.powerhrg.com/backlog_items/PLAY-1472

Icon REPO pr powerhome/playbook-icons#39

Use the new playbook icons package from
powerhome/playbook-icons#39

Hard code SVG files into playbook dist so people who use playbook
without an icons repo can still get some icons

These are some i did there are more though

sheild-icon kits/passphrase/react#tips

angle-down
https://pr3657.playbook.beta.hq.powerapp.cloud/kits/select/react
  • Loading branch information
markdoeswork authored Sep 20, 2024
1 parent 80f9134 commit decb2f3
Show file tree
Hide file tree
Showing 22 changed files with 260 additions and 48 deletions.
4 changes: 2 additions & 2 deletions playbook-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"dependencies": {
"@fortawesome/fontawesome-pro": "6.2.1",
"@mapbox/mapbox-gl-draw": "^1.4.1",
"@powerhome/playbook-icons": "0.0.1-alpha.32",
"@powerhome/playbook-icons-react": "0.0.1-alpha.32",
"@powerhome/playbook-icons": "0.0.1-alpha.36",
"@powerhome/playbook-icons-react": "0.0.1-alpha.36",
"@powerhome/power-fonts": "0.0.1-alpha.6",
"anchor-js": "^5.0.0",
"maplibre-gl": "^2.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,47 @@ import { Header } from "@tanstack/react-table"
import { GenericObject } from "../../types"

import Icon from "../../pb_icon/_icon"
import { getAllIcons } from "../../utilities/icons/allicons"

import { displayIcon } from "../Utilities/IconHelpers"

type SortIconButtonProps = {
header: Header<GenericObject, unknown>
sortIcon?: string | string[]
}

export const SortIconButton = ({ header, sortIcon }: SortIconButtonProps) => {

const firstIcon = displayIcon(sortIcon)[0]
const secondIcon = displayIcon(sortIcon)[1]
const upIcon = getAllIcons()["arrowUpShortWide"].icon as unknown as { [key: string]: SVGElement }
const downIcon = getAllIcons()["arrowDownShortWide"].icon as unknown as { [key: string]: SVGElement }

return (
<>
{header.column.getIsSorted() === "desc" ? (
<div className="sort-button-icon"
key={displayIcon(sortIcon)[0]}
key={firstIcon}
>
<Icon icon={displayIcon(sortIcon)[0]} />
{ firstIcon === "arrow-up-short-wide" ? (
<Icon
className="svg-inline--fa"
customIcon={upIcon}
/> ) : (
<Icon icon={firstIcon} />
)}
</div>
) : (
<div className="sort-button-icon"
key={displayIcon(sortIcon)[1]}
key={secondIcon}
>
<Icon icon={displayIcon(sortIcon)[1]} />
{ secondIcon === "arrow-down-short-wide" ? (
<Icon
className="svg-inline--fa"
customIcon={downIcon}
/> ) : (
<Icon icon={secondIcon} />
)}
</div>
)}
</>
Expand Down
22 changes: 17 additions & 5 deletions playbook/app/pb_kits/playbook/pb_contact/_contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { globalProps } from '../utilities/globalProps'
import Body from '../pb_body/_body'
import Caption from '../pb_caption/_caption'
import Icon from '../pb_icon/_icon'
import { getAllIcons } from "../utilities/icons/allicons"

const contactTypeMap: { [key: string]: string } = {
'cell': 'mobile',
Expand All @@ -18,6 +19,8 @@ const contactTypeMap: { [key: string]: string } = {
'wrong-phone': 'phone-slash',
}

const envelopeIcon = getAllIcons()["envelope"].icon as unknown as { [key: string]: SVGElement }

const formatContact = (contactString: string, contactType: string) => {
if (contactType === 'email') return contactString

Expand Down Expand Up @@ -91,11 +94,20 @@ const Contact = (props: ContactProps): React.ReactElement => {
dark={dark}
tag="span"
>
<Icon
dark={dark}
fixedWidth
icon={contactTypeMap[contactType] || 'phone'}
/>
{contactType === 'email' ? (
<Icon
className="svg-inline--fa envelope"
customIcon={envelopeIcon}
dark={dark}
fixedWidth
/>
) : (
<Icon
dark={dark}
fixedWidth
icon={contactTypeMap[contactType] || 'phone'}
/>
)}
{` ${formatContact(contactValue, contactType)} `}
{contactDetail && (
<Caption
Expand Down
20 changes: 14 additions & 6 deletions playbook/app/pb_kits/playbook/pb_contact/contact.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
classname: "pb_contact_kit",
color: "light",
dark: object.dark
}) do %>
<%= pb_rails("icon", props: {
icon: object.contact_icon,
fixed_width: true,
dark: object.dark
}) %>
}) do %>
<% if contact_type == "email" %>
<%= pb_rails("icon", props: {
custom_icon: Playbook::Engine::root.join(envelope_path),
fixed_width: true,
dark: object.dark
}) %>
<% else %>
<%= pb_rails("icon", props: {
icon: object.contact_icon,
fixed_width: true,
dark: object.dark
}) %>
<% end %>
<%= object.formatted_contact_value if object.contact_value %>

<%= pb_rails("caption", props: {
Expand Down
4 changes: 4 additions & 0 deletions playbook/app/pb_kits/playbook/pb_contact/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def formatted_contact_value
end
end

def envelope_path
"app/pb_kits/playbook/utilities/icons/envelope.svg"
end

private

def formatted_value
Expand Down
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_contact/contact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test('returns correct icon', () => {
expect(screen.getByTestId('test-home').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
expect(screen.getByTestId('test-work').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-office')
expect(screen.getByTestId('test-work-cell').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-laptop')
expect(screen.getByTestId('test-email').querySelector('.pb_icon_kit')).toHaveClass('fa-envelope')
expect(screen.getByTestId('test-email').querySelector('.pb_custom_icon')).toHaveClass('envelope')
expect(screen.getByTestId('test-wrong-phone').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-slash')
expect(screen.getByTestId('test-wrong-type').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
expect(screen.getByTestId('test-extension').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-plus')
Expand Down
7 changes: 4 additions & 3 deletions playbook/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classnames from 'classnames'

import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
import { deprecatedProps, globalProps, GlobalProps } from '../utilities/globalProps'
import { getAllIcons } from "../utilities/icons/allicons"

import datePickerHelper from './date_picker_helper'
import Icon from '../pb_icon/_icon'
Expand Down Expand Up @@ -161,7 +162,7 @@ useEffect(() => {
}
return base
}

const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }

return (
<div
Expand Down Expand Up @@ -231,8 +232,8 @@ useEffect(() => {
id={`${pickerId}-angle-down`}
>
<Icon
className="angle_down_icon"
icon="angle-down"
className="angle_down_icon svg-inline--fa"
customIcon={angleDown}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
>
<%= pb_rails("icon", props: {
classname: "angle_down_icon",
icon: "angle-down"
custom_icon: Playbook::Engine::root.join(angle_down_path)
}) %>
</div>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions playbook/app/pb_kits/playbook/pb_date_picker/date_picker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def icon_wrapper_class
class_string += error_class
class_string
end

def angle_down_path
"app/pb_kits/playbook/utilities/icons/angle-down.svg"
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect'
import weekSelect from "flatpickr/dist/plugins/weekSelect/weekSelect"
import timeSelectPlugin from './plugins/timeSelect'
import quickPickPlugin from './plugins/quickPick'
import { getAllIcons } from '../utilities/icons/allicons';

const angleDown = getAllIcons().angleDown.string

const getPositionElement = (element: string | Element) => {
return (typeof element === 'string') ? document.querySelectorAll(element)[0] : element
Expand Down Expand Up @@ -256,10 +259,10 @@ const datePickerHelper = (config: DatePickerConfig, scrollContainer: string | HT
})
}

// Adding dropdown icons to year and month selects
dropdown.insertAdjacentHTML('afterend', '<i class="far fa-angle-down year-dropdown-icon" id="test-id"></i>')
// Adding dropdown icons to year and month select
dropdown.insertAdjacentHTML('afterend', `<i class="year-dropdown-icon">${angleDown}</i>`)
if (picker.monthElements[0].parentElement) {
return picker.monthElements[0].insertAdjacentHTML('afterend', '<i class="far fa-angle-down month-dropdown-icon"></i>')}
return picker.monthElements[0].insertAdjacentHTML('afterend', `<i class="month-dropdown-icon">${angleDown}</i>`)}
// if (picker.weekElements[0].parentElement){
// return picker.weekElements[0].insertAdjacentHTML('afterend', '<i class="far fa-angle-down year-dropdown-icon" id="test-id"></i>')
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
}
fpInline.config.onChange.push(showAngleDownHandler)
})
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
pointer-events: none;
color: $text_lt_light;
}

.year-dropdown-icon svg, .month-dropdown-icon svg {
width: 16px;
margin-top: 6px;
margin-left: -2px;
}
// Left - Right Arrow Styling
.flatpickr-prev-month {
display: flex;
Expand Down Expand Up @@ -113,4 +117,4 @@
}
}
}
}
}
8 changes: 7 additions & 1 deletion playbook/app/pb_kits/playbook/pb_map/_map_controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import Button from "../pb_button/_button";
import Icon from "../pb_icon/_icon";
import Flex from "../pb_flex/_flex";
import { getAllIcons } from "../utilities/icons/allicons"

type MapControlTypes = {
zoomBtns?: boolean,
Expand All @@ -12,6 +13,8 @@ type MapControlTypes = {
children?: React.ReactNode | React.ReactNode[]
}

const eyeIcon = getAllIcons()["eye"]

const MapControls = ({
zoomBtns,
zoomInClick,
Expand Down Expand Up @@ -42,7 +45,10 @@ const MapControls = ({
<Button className="map-flyto-button"
onClick={flyToClick}
>
<Icon icon="eye" />
<Icon
className="svg-inline--fa"
customIcon={eyeIcon.icon as unknown as { [key: string]: SVGElement }}
/>
</Button>
) : null}
</>
Expand Down
12 changes: 10 additions & 2 deletions playbook/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Icon from '../pb_icon/_icon'
import PbReactPopover from '../pb_popover/_popover'
import TextInput from '../pb_text_input/_text_input'
import { GenericObject } from "../types"
import { getAllIcons } from "../utilities/icons/allicons"

type PassphraseProps = {
aria?: { [key: string]: string },
Expand Down Expand Up @@ -96,6 +97,9 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
/>
)

const shieldIcon = getAllIcons()["shieldCheck"]
const eyeIcon = getAllIcons()["eye"]

return (
<div
{...ariaProps}
Expand Down Expand Up @@ -135,7 +139,8 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
size="xs"
>
<Icon
icon="shield-check"
className="svg-inline--fa"
customIcon={shieldIcon.icon as unknown as { [key: string]: SVGElement }}
marginRight="xs"
/>
{tip}
Expand Down Expand Up @@ -173,7 +178,10 @@ const Passphrase = (props: PassphraseProps): React.ReactElement => {
color="light"
dark={dark}
>
<Icon icon="eye" />
<Icon
className="svg-inline--fa"
customIcon={eyeIcon.icon as unknown as { [key: string]: SVGElement }}
/>
</Body>
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useState } from 'react'

import { getAllIcons } from "../../utilities/icons/allicons"

import Flex from '../../pb_flex/_flex'
import PbReactPopover from '../../pb_popover/_popover'
import Button from '../../pb_button/_button'
Expand Down Expand Up @@ -65,6 +67,7 @@ const toolbarDropdownItems = [
},
]

const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }

const handleTogglePopover = () => {
setShowPopover(!showPopover)
Expand Down Expand Up @@ -92,8 +95,10 @@ for (const { text, isActive, icon } of toolbarDropdownItems) {
<Flex className={showPopover ? "fa-flip-vertical" : ""}
display="inline_flex"
>
<Icon fixedWidth
icon="angle-down"
<Icon
className="svg-inline--fa"
customIcon={angleDown}
fixedWidth
margin-left="xs"
/>
</Flex>
Expand Down Expand Up @@ -125,8 +130,10 @@ const popoverReference = (
<Flex className={showPopover ? "fa-flip-vertical" : ""}
display="inline_flex"
>
<Icon fixedWidth
icon="angle-down"
<Icon
className="svg-inline--fa"
customIcon={angleDown}
fixedWidth
margin-left="xs"
/>
</Flex>
Expand Down Expand Up @@ -169,4 +176,4 @@ const popoverReference = (
)
}

export default ToolbarDropdown
export default ToolbarDropdown
7 changes: 5 additions & 2 deletions playbook/app/pb_kits/playbook/pb_select/_select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
import { globalProps, GlobalProps, domSafeProps } from '../utilities/globalProps'
import type { InputCallback } from '../types'
import { getAllIcons } from "../utilities/icons/allicons"

import Body from '../pb_body/_body'
import Caption from '../pb_caption/_caption'
Expand Down Expand Up @@ -90,6 +91,8 @@ const Select = ({
compactClass
);

const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }

const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className)
const selectBody =(() =>{
if (children) return children
Expand Down Expand Up @@ -134,9 +137,9 @@ const Select = ({
{selectBody}
{ multiple !== true ?
<Icon
className="pb_select_kit_caret"
className="pb_select_kit_caret svg-inline--fa"
customIcon={angleDown}
fixedWidth
icon="angle-down"
/>
:
null
Expand Down
Loading

0 comments on commit decb2f3

Please sign in to comment.