Skip to content

Commit 8d776ed

Browse files
committed
chore(ui-top-nav-bar): integrate useStyle into SubNav to aid testing
1 parent 4dd1ca1 commit 8d776ed

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

packages/ui-top-nav-bar/src/SubNav/index.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424

2525
/** @jsx jsx */
26-
import { jsx, withFunctionalStyle } from '@instructure/emotion'
26+
import { jsx, useStyle, withFunctionalStyle } from '@instructure/emotion'
2727

28-
import { generateStyles } from './styles'
28+
import { generateStyle } from './styles'
2929
import { Link } from '@instructure/ui-link'
3030
import { SubNavProps, MenuItem } from './props'
3131

@@ -34,11 +34,13 @@ import { SubNavProps, MenuItem } from './props'
3434
category: components
3535
---
3636
**/
37-
const SubNav = ({ menuItems, styles }: SubNavProps) => {
37+
const SubNav = ({ menuItems }: SubNavProps) => {
38+
const styles = useStyle({ generateStyle, params: {} })
39+
3840
return (
39-
<div style={styles.container}>
41+
<div css={styles.container}>
4042
{menuItems.map((item: MenuItem) => (
41-
<div style={styles.linkContainer(item)} key={item.title}>
43+
<div css={styles.linkContainer(item)} key={item.title}>
4244
<Link
4345
key={item.title}
4446
href={item.href}
@@ -54,9 +56,5 @@ const SubNav = ({ menuItems, styles }: SubNavProps) => {
5456
)
5557
}
5658

57-
const SC: any = withFunctionalStyle(generateStyles)(SubNav)
58-
59-
SC.displayName = 'SubNav'
60-
61-
export { SC as SubNav }
62-
export default SC
59+
export { SubNav }
60+
export default SubNav

packages/ui-top-nav-bar/src/SubNav/styles.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
2323
*/
24-
import type { SubNavProps } from './props'
2524

26-
const generateStyles = (_props: SubNavProps, theme: any) => {
25+
import { ComponentStyle } from '@instructure/emotion'
26+
27+
type SubNavStyle = ComponentStyle
28+
29+
const generateStyle = (theme: any, params: any): SubNavStyle => {
2730
return {
2831
container: {
2932
marginLeft: '20px',
@@ -57,4 +60,4 @@ const generateStyles = (_props: SubNavProps, theme: any) => {
5760
}
5861
}
5962

60-
export { generateStyles }
63+
export { generateStyle }

0 commit comments

Comments
 (0)