Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Features
- Add `Attachment` component @levithomason ([#220](https://github.com/stardust-ui/react/pull/220))
- Add `atMention="me"` value to Text API @codepretty ([#277](https://github.com/stardust-ui/react/pull/277))

### Documentation
- Add `Theming` guide @almedint, @levithomason ([#152](https://github.com/stardust-ui/react/pull/152))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from 'react'
import { Text } from '@stardust-ui/react'

const TextExampleAtMentionShorthand = () => <Text atMention content="@Russell Wilson" />
const TextExampleAtMentionShorthand = () => (
<div>
<Text atMention content="@someone" />
<br />
<Text atMention="me" content="@me" />
</div>
)

export default TextExampleAtMentionShorthand
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from 'react'
import { Text } from '@stardust-ui/react'

const TextExampleAtMention = () => <Text atMention>@Russell Wilson</Text>
const TextExampleAtMention = () => (
<div>
<Text atMention>@someone</Text>
<br />
<Text atMention="me">@me</Text>
</div>
)

export default TextExampleAtMention
6 changes: 3 additions & 3 deletions src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ComponentVariablesInput, ComponentPartStyle } from '../../../types/them

export interface ITextProps {
as?: any
atMention?: boolean
atMention?: boolean | 'me'
className?: string
content?: any
disabled?: boolean
Expand Down Expand Up @@ -41,8 +41,8 @@ class Text extends UIComponent<Extendable<ITextProps>, any> {
/** Change the default element type of the Text component */
as: customPropTypes.as,

/** Set as @mention Text component */
atMention: PropTypes.bool,
/** At mentions can be formatted to draw users' attention. Mentions for "me" can be formatted to appear differently. */
atMention: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['me'])]),

/** Additional CSS class name(s) to apply. */
className: PropTypes.string,
Expand Down
8 changes: 7 additions & 1 deletion src/themes/teams/components/Text/textStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export default {
}: TextStylesParams): ICSSInJSStyle => {
return {
...(truncated && truncateStyle),
...(atMention && { color: v.atMentionTextColor }),
...(atMention === true && {
color: v.atMentionOtherTextColor,
}),
...(atMention === 'me' && {
color: v.atMentionMeTextColor,
fontWeight: v.atMentionMeFontWeight,
}),
...(disabled && { color: v.disabledTextColor }),
...(error && { color: v.errorTextColor }),
...(success && { color: v.successTextColor }),
Expand Down
9 changes: 7 additions & 2 deletions src/themes/teams/components/Text/textVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export interface ITextVariables {
textWeightRegular: number
textWeightSemibold: number
textWeightBold: number
atMentionTextColor: string
atMentionMeFontWeight: number
atMentionMeTextColor: string
atMentionOtherTextColor: string
disabledTextColor: string
errorTextColor: string
successTextColor: string
Expand All @@ -32,7 +34,10 @@ export interface ITextVariables {

export default (siteVariables): ITextVariables => {
return {
atMentionTextColor: siteVariables.orange04,
atMentionOtherTextColor: siteVariables.brand06,
atMentionMeTextColor: siteVariables.orange04,
atMentionMeFontWeight: siteVariables.fontWeightBold,

disabledTextColor: siteVariables.gray06,
errorTextColor: siteVariables.red,
successTextColor: siteVariables.green04,
Expand Down